title: Closed connection with ORMLite and MySql
body: <p>I have ORMLite configured like in sample 7 of ORMLite docs, but after a while I get Connection closed error</p>
  
  <pre><code>java.sql.SQLException: Connection has already been closed
  at com.j256.ormlite.jdbc.JdbcConnectionSource.getReadWriteConnection   (JdbcConnectionSource.java:177)
  at com.j256.ormlite.jdbc.JdbcConnectionSource.getReadOnlyConnection(JdbcConnectionSource.java:168)
  at com.j256.ormlite.stmt.StatementExecutor.buildIterator(StatementExecutor.java:228)
  at com.j256.ormlite.stmt.StatementExecutor.query(StatementExecutor.java:181)
  at com.j256.ormlite.dao.BaseDaoImpl.query(BaseDaoImpl.java:263)
  at com.tube.auction.db.DbFacade.createOrUpdateUser(DbFacade.java:265)
  </code></pre>
  
  <p>I use only dao beans in code.</p>
  
  <pre><code>&lt;bean id="databaseUrl" class="java.lang.String"&gt;
      &lt;constructor-arg index="0" value="jdbc:mysql://localhost:3306/auction" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="connectionSource" class="com.j256.ormlite.jdbc.JdbcConnectionSource" init-method="initialize"&gt;
      &lt;property name="url" ref="databaseUrl" /&gt;        
      &lt;property name="username" value="root" /&gt;
      &lt;property name="password" value="" /&gt;
  &lt;/bean&gt;
  &lt;bean id="userDao" class="com.j256.ormlite.spring.DaoFactory" factory-method="createDao"&gt;
      &lt;constructor-arg index="0" ref="connectionSource" /&gt;
      &lt;constructor-arg index="1" value="com.tube.auction.dto.User" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>How do I handle Connection closed issues? I can't see any way to force connection restart
  For example
  Note that isOpen() for dao.connection <a href="http://screenshots.ryotsuke.ru/scr_84b6d6e1701c.png" rel="nofollow">returns true</a></p>
  
  <pre><code>-- 1. Can i test connection here and restart it? How? Code snippet?
  try {
      userDao.queryForId(someUserId);
  } catch(SQLException ex) {
     if(is this connection closed?) {
         -- 2. What should I do here to restart connection?
     }
  }
  </code></pre>