Jump to content

[Solved] Java Servlet Error


lauraccc

Recommended Posts

Hi I am receiving this error when using a java servlet; com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: User lauraccc already has more than 'max_user_connections' active connections. Is there any way I can increase my connections

 

 

Link to comment
Share on other sites

Is your code closing its connections when finished? That's the usual issue. Java likes to make persistent connections that don't close on their own, so you need to close them yourself. If you don't, you eventually run out of connections to use.

 

You can also try adding ?max-connections=1 to your JDBC connection string to keep it from opening more than one at a time.

Link to comment
Share on other sites

You don't have any open connections at the moment. If you're seeing this, it's a code issue on your part. Krydos might have some more suggestions for you since limiting connections and closing them when done didn't help.

Link to comment
Share on other sites

One thing that causes issues for a lot of people is there are actually 3 things you have to close to close a java mysql connection. You have to close the resultset, statement, and connection in that order. See https://stackoverflow.com/a/2225275 for example code.

 

Everything about java is designed to work poorly on a multi-user environment. It tries to use persistent connections, it opens hundreds of connections if you let it, it uses massive amounts of memory, and a lot of other unfriendly things. The reason you're seeing that error is because otherwise your java application would likely try to take over the entire server preventing any of the thousands of other accounts from accessing their databases. All of this means that java is much better suited for a single-user environment like a vps. You can take a look at what we offer at https://www.heliohost.org/vps/ I can install the os and tomcat for you if you want to go that route instead of shared hosting which has a lot more restrictions. On a vps you would have unlimited mysql connections.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...