title: MySQLNonTransientConnectionException in JDBC program at run time
body: <p>I have a JDBC MySQL connection in Java. My program works fine for simple execution of query.</p>
  
  <p>If I run the same program for more than 10 hours and execute a query then I receive the following MySQL exception:</p>
  
  <pre><code>com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: 
  Connection.close() has already been called. Invalid operation in 
  this state.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(
    Native Method)
    com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
    No operations allowed after statement closed.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(
    Native Method)
  </code></pre>
  
  <p>I have not used <code>close()</code> method anywhere. I created database connection and opened it forever and always executed query. There is no place where I explicitly mentioned timeout for connection. I am unable to identify the problem.</p>
  
  <p>Here is the code I use for the database connection:</p>
  
  <pre><code> String driver = PropertyReader.getDriver();
   String url = dbURLPath;
   Class.forName(driver);
   connectToServerDB = DriverManager.getConnection(url);
   connectToServerDB.setAutoCommit(false);
  </code></pre>
  
  <p>What causes that exception?</p>