lauraccc Posted March 13, 2019 Posted March 13, 2019 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
wolstech Posted March 13, 2019 Posted March 13, 2019 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.
lauraccc Posted March 14, 2019 Author Posted March 14, 2019 I only have one connection open on this servlet, its as if the system is stilling keeping old java servlets with connections open after I have replaces them?
wolstech Posted March 14, 2019 Posted March 14, 2019 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.
Krydos Posted March 15, 2019 Posted March 15, 2019 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.
Sn1F3rt Posted March 15, 2019 Posted March 15, 2019 Exactly krydos java is much more suited for am environment like vps. Lauraccc I too recommend you to try out a vps for your purpose.
Recommended Posts