This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Servlets and the fly likes Not able to access my datasource using JNDI lookup Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Not able to access my datasource using JNDI lookup" Watch "Not able to access my datasource using JNDI lookup" New topic
Author

Not able to access my datasource using JNDI lookup

Neha Sharma
Ranch Hand

Joined: Jul 13, 2001
Posts: 126
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");}

Thanks
Neha

 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Not able to access my datasource using JNDI lookup
 
Similar Threads
How to Bound JNDI names and references
JNDI Lookup help in websphere 4.0
Not able to get my Datasource using JNDI Lookup
Not able to perform JNDI lookup
Not able to use my datasource using JNDI lookup