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.
Not able to access my datasource using JNDI lookup
Neha Sharma
Ranch Hand
Joined: Jul 13, 2001
Posts: 126
posted
0
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");}