jaganray Posted January 28, 2018 Posted January 28, 2018 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
Krydos Posted January 28, 2018 Posted January 28, 2018 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.
jaganray Posted January 28, 2018 Author Posted January 28, 2018 Even this didnt help. I have close all resources to mysql soon after its task is finished. I have tried it! But this doesnt help.
Krydos Posted January 28, 2018 Posted January 28, 2018 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.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now