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.
subject: Connection polling issue with MySQLNonTransientConnectionException and Java webapp?