I'm using Tomcat connection pooling. I've abstracted the get db and release db functions into an object that looks like this :
This works fine but my problem is that many of my classes get and release database handles using this class. When the class using the db handle releases it tomcat appears to keep it open until the request finishes.
So as an example, if I set my max connections to 3 I can open up to 3 database handles in my assorted classes. Even if I open/close them in sequence I can open no more then maxconnections.
Using Firebird 1.5b6 and Tomcat 4.1 with Struts.
Any ideas? Is this normal Tomcat behavior? I am under the impression that conn.close() means 'return it to the pool immediately'. Are there some better connection pooling technologies available?
Thanks!
Code:
import java.sql.*;
import javax.sql.DataSource;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class DBManager {
static public Connection getDB(){
Connection conn = null;
try {
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource)envCtx.lookup("jdbc/TEST");
conn = ds.getConnection();
} catch (SQLException e){
System.out.println("<HR>SQL Problem<HR>");
System.out.println("<HR>"+e.getMessage()+"<HR>");
} catch (NamingException e) {
e.printStackTrace();
}
System.out.println("DB CREATED");
return conn;
}
static public void releaseDB(Connection conn){
try{
conn.close();
System.out.println("DB RELEASED");
} catch (SQLException e){
System.out.println("releasingDB"+e.getMessage());
}
}
}
This works fine but my problem is that many of my classes get and release database handles using this class. When the class using the db handle releases it tomcat appears to keep it open until the request finishes.
So as an example, if I set my max connections to 3 I can open up to 3 database handles in my assorted classes. Even if I open/close them in sequence I can open no more then maxconnections.
Using Firebird 1.5b6 and Tomcat 4.1 with Struts.
Any ideas? Is this normal Tomcat behavior? I am under the impression that conn.close() means 'return it to the pool immediately'. Are there some better connection pooling technologies available?
Thanks!