context
asked on
Java: JDBC & JNDI: Retrieving a Context
Hi,
Am trying to retrieve a DataSource object (once it has been bound).
I believe I manage to bind the object successfully - a .bindings file is created in the relevant directory.
However, when I try to retrieve the object (doing a lookup), nothing is returned.
Maybe I'm just oversimplifying things...the MyDataSource class just extends DataSource and doesn't do much else.
Relevant code below:
MyDataSource ds = new MyDataSource()
ds.setDescription("Data Source");
ds.setDataSourceName("jdbc /Oracle");
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CO NTEXT_FACT ORY, "com.sun.jndi.fscontext.Re fFSContext Factory");
env.put(Context.PROVIDER_U RL, "file:c:\\JDBCDataSource") ;
Context ctx = new InitialContext(env);
// Register the data source to JNDI naming service
// for application to use
ctx.ind("jdbc/Oracle", ds);
// The following call will return null
DataSource new_ds = (DataSource) ctx.lookup(jdbc/Oracle);
Thanks,
Andy
Am trying to retrieve a DataSource object (once it has been bound).
I believe I manage to bind the object successfully - a .bindings file is created in the relevant directory.
However, when I try to retrieve the object (doing a lookup), nothing is returned.
Maybe I'm just oversimplifying things...the MyDataSource class just extends DataSource and doesn't do much else.
Relevant code below:
MyDataSource ds = new MyDataSource()
ds.setDescription("Data Source");
ds.setDataSourceName("jdbc
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CO
env.put(Context.PROVIDER_U
Context ctx = new InitialContext(env);
// Register the data source to JNDI naming service
// for application to use
ctx.ind("jdbc/Oracle", ds);
// The following call will return null
DataSource new_ds = (DataSource) ctx.lookup(jdbc/Oracle);
Thanks,
Andy
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.