• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Not able to access my datasource using JNDI lookup

 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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");}

Thanks
Neha

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic