0
votes

I'm connecting my Java application via JDBC driver and Tomcat configurations. I used this class to define my configurations. But sometimes, I got following exceptions:

  • com.mysql.jdbc.exceptions.MySQLTimeoutException: Statement cancelled due to timeout or client request
  • java.sql.SQLException: Query execution was interrupted
  • java.sql.BatchUpdateException: Statement cancelled due to timeout or client request

But there is not much load on database, so I think the problem is about my configuration. Here are some of my configs:

  • maxActive = 100
  • minIdle = 10
  • initialSize = 10
  • maxWait = 10000
  • maxIdle = 15

These are for some heavily loaded system. So I need to observe if my pool size is enough and other things like available connection count at any time. Is there any nice way of monitoring inside of connection pools?

2

2 Answers

1
votes

For the timeout exceptions, consider the following pseudocode:

if(!connection.isValid())
  connection = getNewConnection();
resultSet rs = connection.execute(qry);

Basically check if your connection has timed out before you execute the query.

If your query was interrupted, theres not much you can do other than to rollback the transaction and try again.

0
votes

Enable JMX and tomcat will register your datasources with it's mbean server. You can then use jconsole to look at the connection pool details.