• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

closing pooled connection with WS naming service(jndi)

Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
    Bookmark Topic Watch Topic
  • New Topic