File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Websphere and the fly likes How many JNDI lookup for datasource in websphere Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "How many JNDI lookup for datasource in websphere" Watch "How many JNDI lookup for datasource in websphere" New topic

How many JNDI lookup for datasource in websphere

khan gul
Ranch Hand

Joined: Jan 27, 2011
Posts: 30
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?

wood burning stoves
subject: How many JNDI lookup for datasource in websphere
It's not a secret anymore!