This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connection polling issue with MySQLNonTransientConnectionException and Java webapp?

Martin Oshea
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have a Java, JSP and MySQL application running under Apache Tomcat 6.0.26 which I've been testing with JMeter. What I find is that for a simple test having 10 users logging in and displaying a JSP which is populated from several database reads is fine.

But when I increase the number of users in JMeter to 20+, logging in starts to fail with HTTP request 500. Checking the logs I find that I am getting large numbers of MySQLNonTransientConnectionExceptions as follows:

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.

So this indicates that there's an issue either with the connection polling through Apache Tomcat 6.0.26 or MySQL Community Server 5.X.

The relevant part of the application's context.xml file in the project reads as follows:

I've set maxActive above to -1 on the understanding that this is unlimited. I think that the MySQL error is because MySQL is refusing the connections.

Am I correct here? Can anyone suggest a workaround?

Typically, my database operations are as follows:

And there can be quite a few of these per page.



  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic