This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Problem retrieving connection when stress testing. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem retrieving connection when stress testing." Watch "Problem retrieving connection when stress testing." New topic
Author

Problem retrieving connection when stress testing.

Andres Delrotti
Ranch Hand

Joined: Aug 11, 2005
Posts: 134
Hello friends,

I have this problem at getting connections when I stress test some of the Use Cases of my application. I used the OpenSTA testing tool for testing 100 users concurrently doing an application use case. Now, this is the problem that happens, when I do this test for 100 users, it really takes a very very long time for the datasource object to return a connection. I don't have an idea why.

After waiting for it to return a connection, this exception happens instead:

com.ibm.db2.jcc.b.SQLException
at com.ibm.db2.jcc.b.l.a(l.java(Compiled Code))
at com.ibm.db2.jcc.a.bb.h(bb.java:541)
at com.ibm.db2.jcc.a.bb.g(bb.java:443)
at com.ibm.db2.jcc.a.bb.d(bb.java:276)
at com.ibm.db2.jcc.DB2PooledConnection.connect (DB2PooledConnection.java:107)
.....
....


Here's part of the code:

private static final Datasource myDataSource

Connection cnx = null;
InitialContext ctx = new InitialContext();
if (myDataSource==null){
myDataSource = (DataSource) ctx.lookup("jdbc/mydatasource");
}
cnx = myDataSource.getConnection(); <-- this is the part where it takes so long and also where the exception happens


They told me that my application may have a connection leak but I already double checked the source codes and there seems to be no problem. I've already got a connection.close() in the finally block of every method in my Data Access Objects (DAO).

Could it be that the problem is in the database? or maybe the datasource settings in the Websphere Application Server where my application in deployed?

I'd appreciate any form of help. Thanks
Masoud Kalali
Author
Ranch Hand

Joined: Jul 08, 2004
Posts: 531

Please post a more complete exception trace.
meanwhile you can check to see
1-what is connection pool size / what is its maximum size ,
you are testing 100 cuncurrent user so based on your operations time consuming you may need to increase the pool size.
2-you may also check to see how much connection is in use , you can check this in application server Administration console.
3-try to test the application with an smaller count of cuncurrent users for a longer time, if your application has connection leak it will show itself there.


Masoud Kalali
Software Engineer - My Weblog - GlassFish Security
Andres Delrotti
Ranch Hand

Joined: Aug 11, 2005
Posts: 134
Originally posted by Masoud Kalali:
Please post a more complete exception trace.
meanwhile you can check to see
1-what is connection pool size / what is its maximum size ,
you are testing 100 cuncurrent user so based on your operations time consuming you may need to increase the pool size.
2-you may also check to see how much connection is in use , you can check this in application server Administration console.
3-try to test the application with an smaller count of cuncurrent users for a longer time, if your application has connection leak it will show itself there.



1. I used the default values: min = 1 , max = 10
2. How could I do that? What section in the Admin console?
3. I tried it for 20 concurrent users and there was no problem. It starts "hanging" when the concurrent users are increased to about 40-50 users.
 
jQuery in Action, 2nd edition
 
subject: Problem retrieving connection when stress testing.
 
Similar Threads
How to specify the name of the database
Connection problem on Stress Testing
Webapp hang when calling stored procedure
Connection Pooling Managment
Downloaded file contains garbage value