title: MySQL connection reset in java
body: <p>I have a java code that generate and fill tables to MySQL database. </p>
  
  <p>The method is to create a connection to generate a table and then close that connection afterward.
  Then create new connection to fill the table and so on. </p>
  
  <p>I have about 14000 table to generate. The problem is that after generating about 800 tables I got this message and I have to restart mysql again.</p>
  
  <p>Is there a cap to the number of connection I could create? is there anyway to increase it? Any Ideas?</p>
  
  <p>Thanks </p>
  
  <pre><code>java.sql.SQLException: Communication link failure: java.net.SocketException, underlying cause:  Connection reset
  
  ** BEGIN NESTED EXCEPTION ** 
  
  java.net.SocketException
  MESSAGE: Connection reset
  
  STACKTRACE:
  
  java.net.SocketException: Connection reset
      at java.net.SocketInputStream.read(SocketInputStream.java:189)
      at java.net.SocketInputStream.read(SocketInputStream.java:121)
      at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
      at java.io.BufferedInputStream.read(BufferedInputStream.java:265)
      at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:1449)
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1826)
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1803)
      at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:2353)
      at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:750)
      at com.mysql.jdbc.Connection.createNewIO(Connection.java:1627)
      at com.mysql.jdbc.Connection.&lt;init&gt;(Connection.java:427)
      at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:395)
      at java.sql.DriverManager.getConnection(DriverManager.java:664)
      at java.sql.DriverManager.getConnection(DriverManager.java:247)
      at db.DbConnection.establishConnection(DbConnection.java:21)
      at db.DbActivities.addToDocSent(DbActivities.java:125)
      at db.DbGeneration.main(DbGeneration.java:58)
  
  
  ** END NESTED EXCEPTION **
  </code></pre>