Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Can't access JDBC Datasource using JNDI  RSS feed

 
Tony Moses
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to access an Oracle Database by building/instantiating a javax.sql.DataSource object through accessing a registered JDBC datasource (Oracle Type 4 Driver) using JNDI. (Note: I am not using EJB's).
The code is as follows:
--------------------------------------------------------
Properties env = new Properties();
env.put("java.naming.factory.initial", "com.sun.jndi.cosnaming.CNCtxFactory");
//env.put("java.naming.provider.url", "iiop://decipher:389");
Context ctx = new InitialContext(env);
// Define JNDI InitialContext object.
//InitialContext ctx = new InitialContext();
// Look up data source in InitialContext.
ds = (DataSource)ctx.lookup("java:comp/env/jdbc/" + dsName);
dbConn = ds.getConnection();
----------------------------------------------------------
(Where dsName is the JNDI Name that I gave the JDBC datasource in the iPlanet Application Server 6.0 Administration Tool.)
Notice that, at first, I tried to instantiate the InitialContext object without any arguments. This gave me the error:
java.lang.NullPointerExceptionjavax.naming.NameNotFoundException
at com.netscape.server.jndi.RootContext.resolveCtx(Unknown Source)
I then tried to instantiate the InitialContext object with a Properties object as an argument. This gave me the error:
javax.naming.CommunicationException: Cannot connect to ORB. Root exception is org.omg.CORBA.COMM_FAILURE: minor code: 1398079490 completed: No
What am I doing wrong here?
Note: For what its worth - this code worked fine in JRun.
 
Sandep Chaturvedi
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you used this initial context earlier. If not just make sure that you have all netscape classes in the classpath
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!