Jump to content

user has max user connections (mysql)


jaganray

Recommended Posts

I have a war file basically servlet and jsp pages. A new online based shopping website. I get mysql max user connections error in jdbc.

 

In my website I am able to only send data to sql from two simultaneous pages.

 

My minimum requirements is to support atleast 20 users at same time. Can anyone please increase the number of active connections in .conf file of tomcat

 

post-104745-0-00926800-1517142918_thumb.png

Link to comment
Share on other sites

Make sure you close all mysql connections as soon as you are done with them. Do something like this:

Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;

try {
    // Do stuff
    ...

} catch (SQLException ex) {
    // Exception handling stuff
    ...
} finally {
    if (rs != null) {
        try {
            rs.close();
        } catch (SQLException e) { /* ignored */}
    }
    if (ps != null) {
        try {
            ps.close();
        } catch (SQLException e) { /* ignored */}
    }
    if (conn != null) {
        try {
            conn.close();
        } catch (SQLException e) { /* ignored */}
    }
}
Sites that close their mysql connections can handle thousands of visitors. Sites that use persistent connections can generally only serve a very small number of visitors. The default in java is to treat all connections as persistent unless you code it otherwise. The limit is in place to prevent one user from blocking anyone else from connecting to mysql.
Link to comment
Share on other sites

Well, if you can't get your code to close the connections you can always try a different language. For instance you could have the remote java application connect to a php script on the server. Closing mysql connections in php is pretty easy. The other option I can think of is to get a vps https://www.heliohost.org/partners/vps that way you have the whole server to yourself and java can open howeveer hundreds of connections as it wants to. Any shared host you find (even paid ones) will have a limit on the number of simultaneous connections.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...