tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: Tomcat App becomes Unresponsive
Date Mon, 21 Jan 2008 15:19:10 GMT
Hash: SHA1


tc wrote:
| The developers think there may some issue with the database.  They have
| also done multi-user testing without being able to reproduce the problem.

If they think it's the database, it's probably their code interacting
with the database. MySQL is pretty stable, although I have had some
legitimate problems with it in the past.

The most likely problem is that you have code that is not properly
cleaning up after JDBC calls.

Are you using a connection pool? If so, which one?

You need to make sure that you call "close" on /everything/ when you're
done with your Connection, Statement (and subclass), and ResultSet (and
subclass) objects. Check to make sure that those close calls are done in
"finally" blocks, and that a failure to close a ResultSet does not cause
an exception to be thrown that avoids the Connection close.

For example:

Connection conn = getConnection();

PreparedStatement ps = conn.prepareStatement("SELECT 1");

ResultSet rs = ps.executeQuery();



return null;

This is not good. What you really need is this:

Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;

~    conn = getConnection();
~    ps = ...;
~    rs = ...;

~    ...
~    if(null != rs)
~        try { rs.close(); } catch (SQLException sqle) { /* log */ }
~    if(null != ps)
~        try { ps.close(); } catch (SQLException sqle) { /* log */ }
~    if(null != conn)
~        try { conn.close(); } catch (SQLException sqle) { /* log */ }

Note how all the cleanup is done in the finally block (so the cleanup
code will run even during an exception situation), and that each "close"
is called in its own try/catch block: this prevents the failure to close
the (e.g.) ResultSet from preventing the Statement or Connection from
closing. Remember to log anything weird.

| I'm looking for pointers to any resources on the web or elsewhere that can
| help me track down the problem, or ideas about where to look, or what we
| can do to improve post-freeze diagnosis of this problem.

When the app freezes, what are yout threads doing? Does the server stop
serving requests entirely, or do some of them work while others do not?

Good luck,
- -chris
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla -


To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message