Hi All,
My web application is using up all connections after running for a while.
It's quite obvious that I'm not using the connection pool as it was designed
to be used. The only way I can get these connections back is by restarting
the Tomcat. I have ojdbc14.jar in the following directories:
$CATALINA_HOME/commons/lib directory &
$CATALINA_HOME/webapps/<myWebApp>/WEB-INF/lib.
This code creates my connection Pool
------------------------------------
private void createConnectionPool( ) {
try {
// Create a OracleConnectionPoolDataSource instance.
connectionPoolDS = new OracleConnectionPoolDataSource( );
String url = "jdbc:oracle:thin:@194.26.151.17:1521:mosaic";
connectionPoolDS.setURL( url );
// Set the user name.
connectionPoolDS.setUser("mosaicuser");
// Set the password.
connectionPoolDS.setPassword("mosa1c");
}
catch ( SQLException ex ) { // Catch SQL errors.
//context.log( ex.toString( ) ); // log errors.
}
}
This code creates a PooledConnection.
-------------------------------------
public static synchronized PooledConnection getPooledConnection(){
try{
pooledconn = connectionPoolDS.getPooledConnection();
}catch(SQLException sqle){
sqle.printStackTrace();
}
return pooledconn;
}
In my LoginServlet, I create a new PooledConnection, which I add to the
Servlet Context:
PooledConnection pc = ConnectionFactory.getInstance.getPooledConnection();
ServletContext ctx = getServletContext();
ctx.setAttribute("pooled_conn", pc);
On an JSP Page:
ServletContext ctx = getServletContext();
PooledConnection pc = (PooledConnection)ctx.getAttribute("pooled_conn");
Connection con = pc.getConnection
//do a few things with the connection
try{
if (con != null){
con.close();
} // I'm assumingthis returns the connection to the Pool
}catch(SQLException sqle){
sqle.printStackTrace();
}
Any help to solve this mystery would be very much appreciated.
Kind Regards,
Rudi
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]