• 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

JNDI lookup for DataSource

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<code>
try
{
javax.naming.Context jndiCntx=new javax.naming.InitialContext();
javax.sql.DataSource ds
=(javax.sql.DataSource)jndiCntx.lookup("jdbc/home");
c = ds.getConnection(getUID(),getPassword().trim());
s = c.createStatement();
//}catch(javax.naming.NamingException e){e.printStackTrace();}
}catch(Exception e){Log.print(":Exception = "+e);
</code>
In the above code i am trying to get connected to the DB2. Working with Webspehere 5.0. I am new to Webspehere. Created a JDBC Provider for DB2. Created a datasource with jndi name 'jdbc/home'.
**The exception i am getting is:
Exception = com.ibm.websphere.ce.cm.ConnectionWaitTimeoutException: Connection not available, Timed out waiting.
Is there anything else to be done to get the connection?
Thank you
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am not exactly sure of your problem, but I would make a try to help you. Normally this Exception occurs if all the Connections in the pool are used and when a request for a new Connection is given to the DataSource after the Connection timeout, it throws this Exception. May be by increasing the timeout time or by increasing the connections in the pool could solve the problem.
At the same time check it ther is any Connection leaks in the code. Whenever Connection use is complete close (it would be better you close the connection in finally, so that even in the case of Exception the Connection would be closed).
Suttan
 
    Bookmark Topic Watch Topic
  • New Topic