Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How many JNDI lookup for datasource in websphere  RSS feed

khan gul
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a Question on JNDI lookup for datasource in websphere. My understanding is that if you have configured a connection pool on server like web sphere then the JDNI binding should occur once to initialize the DataSource object. Then later multiple threads can use this single DataSource object and call the getConnection() to get new connection from the pool. Is it correct?

java code below:

private static OLBDataSource instance = null;
private DataSource dataSource = null;

//make sure there is only one instance of OLBDataSource. aali
static {
try {
instance = new OLBDataSource();
} catch (NamingException e) {
instance = null;

private OLBDataSource() throws NamingException {
try {
Properties params = new Properties();

// Look up the datasource configured on the server.
InitialContext context = new javax.naming.InitialContext(params);
dataSource = (DataSource) context.lookup("jdbc/myDB");


public static DataSource getMyConnection(){
return dataSource;

//Now multiple threads can call the above getMyConnection() method and then call getConnection() to get unique connection from the thread pool.

Is my understanding correct?

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