• Post Reply Bookmark Topic Watch Topic
  • New Topic

Not able to access my datasource using JNDI lookup  RSS feed

Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I'm trying the following code to access my datasource, which is created in websphere 4.0, and I'm getting a null pointer Exception. I've just created the DSN but in the websphere documentation it says you have to bind your dsn to the JNDI how do you do that ? do you perform this programmatically or is there a way to do it in websphere. Do I need to add anything in my code.
java.util.Properties parms = new java.util.Properties();
parms.setProperty Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
Context ctx = new javax.naming.InitialContext(parms);
ds = (javax.sql.DataSource)ctx.lookup("jdbc/OracleDSN");
Con = ds.getConnection();
}catch (NullPointerException ex) {out.println("NullPointerException Exception while creating the datasource");}
catch (Exception ex) {out.println("Exception while creating the datasource");}


  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!