An exception occurred in the internship
Com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:Data Source rejected establishment of Connection, message from server: "Too many connections"
See a lot of solutions on the Internet are basically said to modify the MySQL configuration file, open the MySQL installation directory open My.ini find Max_connections (in about 93rd line) By default is 1001-like settings to 500~1000 more appropriate, restart MySQL, This 1040 error will be solved.
max_connections=1000
But I tried, did not solve the exception, the reason for this exception is not only the one mentioned above, there is another possibility is that the code opened too many connections, but forgot to close in the finally block, resulting in the processing of large data, throw an exception. The following code will not have an exception.
try{
conn=good.getconnection ();
stmt = Conn.createstatement (resultset.type_scroll_insensitive
, resultset.concur_updatable);
String sql1= "INSERT into cat_garbage values ('" +rs.getint ("id") + "', '" +rs.getint ("CID") + "', '" +rs.getstring ("name") + " ', ' "+rs.getstring (" keyword ") +" ') ";
Stmt.executeupdate (SQL1);
}
catch (sqlexception| classnotfoundexception| IOException e)
{
e.printstacktrace ();
}
Finally
{
if (stmt!= null)
stmt.close ();
if (conn!= null)
conn.close ();
}
}