This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JNDI lookup for DataSource

 
prachi jahagirdar
Greenhorn
Posts: 11
  • 0
  • 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
 
Suttan Pym
Ranch Hand
Posts: 46
  • 0
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic