SJSAS 9
Well I have decided to go with the Java EE SDK 5, which includes SJSAS 9. It is installed and working. after having my developers deploy a couple of small j2ee modules, we ran into a problem. When there are two modules running at once we receive the following error:
[#|2006-07-27T08:51:11.131-0400|INFO|sun-appserver-pe9.0|javax.enterprise.system.stream.out|_ThreadID=18;_ThreadName=httpWorkerThread-9090-3;|
SQLException: java.sql.SQLException: Error in allocating a connection. Cause: In-use connections equal max-pool-size and expired max-wait-time. Cannot allocate more connections.|#]
each application has is own jdbc pool and resource. Both applications reside in the same domain, and are running on the same server. The databases that they are connecting to are on different servers. Applications that do not use jdbc are not affected.
Here is what i believe is happening, somehow the pools for jdbc connections are tied together, even though the pools are identified as being separate they are still sharing the same resources. Perhaps there is a connection leak, or connections are not being closed by the appserver. Upping the max-connections only prolongs the amount of time before the connection slow down and error. Has anyone else run into this problem?
[1299 byte] By [
cod3fr3ak] at [2007-11-26 9:05:03]

# 1
After a very exhausting two weeks, I think I have come a little closer to understanding my connection pooling problems.
A bit of background:
I have two applications that i need to migrate to a unified web environment. Each application has its own database, on its own server. I created two pools and two jdbc resources. One for each application. If i startup one application and access the index.jsp page, everything is fine. If i then access the second application server the first one gets the error in my first post.
I found that when I put the two contenting applications on separate domains the connection pooling problem goes away. This would cause unacceptable admin overhead.
So now the question is does the Sun Java System Application Server, do application level JDBC resources? It seems that even though the databases are on different servers, and there are separate pools for each server, there is only ONE pool for jdbc resouces - hence a global JDBC resource pool. So if Application A hogs a bunch of jdbc resources Application B will not be able to connect even if using a different pool.
If this is the case has anyone found work arounds. I can not believe that this is the case.
# 2
Hi,
The probable reason why you run into "max-wait-time expired, no more connections to provide" is, your application may not be closing the connections properly.
If the connections are not closed by the application, it will not be returned to the pool and eventually pool will loose all the connections and throw the above exception.
if an exception occurs in the code snippet below, connection will not be closed and hence wont be returned to pool.
try{
getConnection(); // dataSource.getConnection();
performSomeOperation(); // exception occurs
performDBOperation(); // exception occurs
closeConnection(); // conn.close();
}catch(Exception e){}
When this happens, connection close() will not get called.
Hence It has to be:
try{
getConnection(); // dataSource.getConnection();
performSomeOperation(); // exception occurs
performDBOperation(); // exception occurs
}catch(Exception e){
//log the exception
}finally{
if(conn != null){ conn.close();}
}
Further, you can keep track of getConnections and closeConnections.
Have a single point of invocation to all getConnection (similarly for closeConnection)
eg:
Connection DBManager.getConnection(){
System.out.println("getConnection" + con);
}
DBManager.closeConnection(Connection conn){
System.out.println("closeConnection" + con);
}
When you get max-wait-time expired, check whether number of getConnection : xyz & closeConnection : xyz
matches.
If you are still facing the problems, please post your connection pool configuration,
code snippet to get data source, get connection, close connection.
Thanks,
-Jagadish