Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Getting DataSource object through JNDI in WebSphere 6.1

 
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello friends,

I have to write a standalone java application which should get the DataSource object from WebSphere 6.1. DataSource object is of type oracle and is successfully configured in WebSphere's JNDI and I was able to TestConnection successfully. The standalone application is outside websphere context and is configured as a batch process which runs at scheduled time. This application should get the datasource object from JNDI and perform database operations.The main reason for doing this is I want to get rid of storing database credentials in properties file. I created a simple java project and added the following classpath libraries

rsahelpers.jar
rsadbutils.jar
ojdbc14.jar
com.ibm.ws.emf_2.1.0.jar
com.ibm.ws.runtime_6.1.0.jar
com.ibm.ws.admin.client_6.1.0.jar


The program in java file is as follows,


Problem: I want to use dataSource.getConnection() instead of dataSource.getConnection("username", "password"); because the later one involves hardcoding of username and password in java file. However when I invoke getConnection() it throws the following exception.



But this datasource configured in websphere has already been supplied username and password otherwise the testconnection would have failed. My question is why cant I use dataSource.getConnection() method ?
If I supply the username and password to getConnection method then everything works fine. I can see the print statements on console.

Does anyone know the solution to this problem ?
Waiting for your reply.

Thank you,
Rohit.
 
I miss the old days when I would think up a sinister scheme for world domination and you would show a little emotional support. So just look at this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!