wood burning stoves 2.0*
The moose likes Websphere and the fly likes closing pooled connection with WS naming service(jndi) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "closing pooled connection with WS naming service(jndi)" Watch "closing pooled connection with WS naming service(jndi)" New topic
Author

closing pooled connection with WS naming service(jndi)

prashant patel
Ranch Hand

Joined: May 02, 2000
Posts: 69
hi,
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()
{
try{
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.
thanks.

prashz
 
Don't get me started about those stupid light bulbs.
 
subject: closing pooled connection with WS naming service(jndi)
 
Similar Threads
WebSphere Studio v5 & Connection Pooling
does gc still have a chance to do its job if i kill the java process
How To Access Objects Returned From A Helper/Utility Class?
Create ConnectionPool in ServletContextListener
Syntax Error On Token "(", ";" expected