on 03-22-2005 10:35 AM
Hi,
I get the error 'Path to object does not exist at java:comp, the whole lookup name is java:comp/env/jdbc/UDF_Oracle_XIFunction' when I want to connect the DataSource.
This is the code in my java application:
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/UDF_Oracle_XIFunction");
Connection con = ds.getConnection();
The DataSource alias name made in the JDBC Connector of the Visual Administrator is:
UDF_Oracle_XIFunction
I have a java and not a j2ee application. Is this the problem? But I need a jar-file because only jar- and zip.files are possible to upload into the imported archives for the message mappings in XI.
Have anybody an idea how to use the alias in the right way?
Thanx for help,
Susanne
Hi Susanne,
When you lookup a resource factory (what is a DataSource) from a non-J2EE component, you don't have the JNDI environment that J2EE components have.
This means you must not use the prefix <i>"java:comp/env"</i> but rather the path <i><b>"jdbc/client/<data-source-name>"</b></i>.
However, in this case you cannot use JTA transactions and there's no connection pooling, i.e. it's equivalent to calling DriverManager.getConnection(<connection-string>).
One more remark: if your application is not running on the server, you must provide the parameters when creating an InitialContext in the form:
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");
p.put(Context.PROVIDER_URL, "<host>:<port>");
p.put(Context.SECURITY_PRINCIPAL, "<user>");
p.put(Context.SECURITY_CREDENTIALS, "<password>");
InitialContext ctx = new InitialContext(p);
Hope that helps,
Vladimir
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.