Hello tomcat users!
I have a problem using the connection pool in Tomcat. The function
getConnection() throws the following error message:
[Error message]
When trying to get a Connection an SQLExcpetion occurred:
java.sql.SQLException: Already closed.
at
org.apache.tomcat.dbcp.dbcp.PoolableConnection.close(PoolableConnection.java:84)
at
org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:181)
at
org.metria.kiruna.profs.eniro.db.DatabaseController.getConnection(DatabaseController.java:136)
[DatabaseController.java]
protected Connection getConnection(){
try{
Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:comp/env");
DataSource ods = (DataSource) envContext.lookup("jdbc/yyy");
Connection conn = ods.getConnection();
Connection dconn = ((DelegatingConnection)
conn).getInnermostDelegate();
// if( conn != null && !conn.isClosed() ) // Line 135
conn.close(); // Line 136
return dconn;
}catch( SQLException sqle ){
System.err.println("When trying to get a Connection an
SQLExcpetion occured.");
sqle.printStackTrace();
}catch( NamingException ne ){
System.err.println("When trying to get a Connection an
NamingException occured.");
System.err.println(ne);
}
return null;
}
[Context.xml]
<Resource accessToUnderlyingConnectionAllowed="true"
auth="Container"
driverClassName="oracle.jdbc.OracleDriver"
maxActive="30"
maxIdle="10"
maxWait="1000"
name="jdbc/yyy"
username="xxx"
password="xxx"
type="javax.sql.DataSource"
url="jdbc:oracle:thin:@drone:1521:top" />
If the outer connection is left open ( line 135, 136 is deleted) then
all connections are used until "maxActive" connections are created.
The program uses Tomcat 5.5.26 and Oracle 10.2.3.0.
Does anybody have an idea of why I can't close the outer connection so
that the connections can be returned to the pool when I am done?
/ Petter
---------------------------------------------------------------------
To start a new topic, e-mail: [email protected]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]