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

closing pooled connection with WS naming service(jndi)  RSS feed

prashant patel
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The follwing code gets me a pooled connection from the lookup service of websphere.

import java.sql.*;
import javax.sql.*;
import javax.naming.*;
public class DbConnection
private Connection con;
public DbConnection()
Context ctx = new InitialContext();
DataSource ds=(DataSource)ctx.lookup("jdbc/Default DataSource");
con = ds.getConnection("username","passwd");
}catch(NamingException ne){
System.err.println("Naming Exception " + ne.getMessage());
}catch(SQLException sql){
System.err.println("SQLException " + sql.getMessage());
public Connection getConnection()
return con;
after sucessfully using the pooled connection, when we close the
connection using con.close() method the connection should be returned to the pool, to my notice the application is really slow and the guess is the connection are not been returned to the pool, this procedure is described in the infocenter avaiable at the ibm site. when i was a normal connection we used to moniter the connection status by issuing a sql statement and came to know how many connection are been taken up, in websphere how can i know how many connections are been used and how many in the pool. I have also increased the connection to 50 pooled connection throught the websphere java console.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!