Jump to content


Photo

[Solved] Java Servlet Error


  • This topic is locked This topic is locked
5 replies to this topic

#1 lauraccc

lauraccc

    Rank I Member

  • Members
  • Pip
  • 17 posts

Posted 13 March 2019 - 12:57 PM

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

 

 



#2 wolstech

wolstech

    Rank X Member

  • Root Admin
  • 10,161 posts
  • Gender:Male
  • Location:Pennsylvania

Posted 13 March 2019 - 02:58 PM

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.


Please do not PM me for support. Posting on our forums lets all of us learn.

Do you play Minecraft? | Server Monitors | And the Dumbass of the Decade award goes to...


#3 lauraccc

lauraccc

    Rank I Member

  • Members
  • Pip
  • 17 posts

Posted 14 March 2019 - 02:37 AM

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?



#4 wolstech

wolstech

    Rank X Member

  • Root Admin
  • 10,161 posts
  • Gender:Male
  • Location:Pennsylvania

Posted 14 March 2019 - 06:25 PM

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.


Please do not PM me for support. Posting on our forums lets all of us learn.

Do you play Minecraft? | Server Monitors | And the Dumbass of the Decade award goes to...


#5 Krydos

Krydos

    Rank X Member

  • Root Admin
  • 17,844 posts
  • Gender:Male

Posted 15 March 2019 - 12:06 AM

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.

#6 sohamb03

sohamb03

    Rank II Member

  • Members
  • PipPip
  • 55 posts
  • Gender:Male
  • Location:India
  • Interests:Ethical Hacking
    Web Designing(Wordpress)
    App Development

Posted 15 March 2019 - 09:14 AM

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.
Soham Bhattacharyya
Administrator and C.E.O.
Panther WebTech




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users