title: A PooledConnection that has already signalled a Connection error is still in use
body: <p>I post a query <a href="https://stackoverflow.com/questions/14106239/how-to-use-the-named-parameters-with-contains">here</a>
  I this error appears after running the hibernate query and I don't know what does it mean.
  So I rerun the query few minutes later, then I haven't the error but I wanna know how I get it and how to fix it.</p>
  
  <pre><code>WARN  com.mchange.v2.c3p0.impl.NewPooledConnection - [c3p0] A PooledConnection that has already signalled a Connection error is still in use!
  WARN  com.mchange.v2.c3p0.impl.NewPooledConnection - [c3p0] Another error has occurred [ java.sql.SQLException: Invalid state, the Connection object is closed. ] which will not be reported to listeners!
  java.sql.SQLException: Invalid state, the Connection object is closed.
      at net.sourceforge.jtds.jdbc.ConnectionJDBC2.checkOpen(ConnectionJDBC2.java:1713)
      at net.sourceforge.jtds.jdbc.ConnectionJDBC2.clearWarnings(ConnectionJDBC2.java:2020)
      at com.mchange.v2.c3p0.impl.NewProxyConnection.clearWarnings(NewProxyConnection.java:933)
      at org.hibernate.util.JDBCExceptionReporter.handleAndClearWarnings(JDBCExceptionReporter.java:71)
      at org.hibernate.util.JDBCExceptionReporter.logAndClearWarnings(JDBCExceptionReporter.java:49)
      at org.hibernate.jdbc.ConnectionManager.closeConnection(ConnectionManager.java:472)
      at org.hibernate.jdbc.ConnectionManager.aggressiveRelease(ConnectionManager.java:429)
      at org.hibernate.jdbc.ConnectionManager.afterStatement(ConnectionManager.java:304)
      at org.hibernate.jdbc.AbstractBatcher.closePreparedStatement(AbstractBatcher.java:572)
      at org.hibernate.jdbc.AbstractBatcher.closeStatement(AbstractBatcher.java:291)
      at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:307)
      at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:234)
      at org.hibernate.loader.Loader.getResultSet(Loader.java:1967)
      at org.hibernate.loader.Loader.doQuery(Loader.java:802)
      at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
      at org.hibernate.loader.Loader.doList(Loader.java:2533)
      at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
      at org.hibernate.loader.Loader.list(Loader.java:2271)
      at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:316)
      at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1842)
      at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
      at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:157)
  org.hibernate.exception.JDBCConnectionException: could not execute query
      at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:99)
      at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
      at org.hibernate.loader.Loader.doList(Loader.java:2536)
      at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
      at org.hibernate.loader.Loader.list(Loader.java:2271)
      at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:316)
      at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1842)
      at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
      at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:157)
  Caused by: java.sql.SQLException: I/O Error: Software caused connection abort: recv failed
      at net.sourceforge.jtds.jdbc.TdsCore.executeSQL(TdsCore.java:1053)
      at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:465)
      at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:778)
      at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
      at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
      at org.hibernate.loader.Loader.getResultSet(Loader.java:1953)
      at org.hibernate.loader.Loader.doQuery(Loader.java:802)
      at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
      at org.hibernate.loader.Loader.doList(Loader.java:2533)
      ... 8 more
  Caused by: java.net.SocketException: Software caused connection abort: recv failed
      at java.net.SocketInputStream.socketRead0(Native Method)
      at java.net.SocketInputStream.read(SocketInputStream.java:168)
      at java.net.SocketInputStream.read(SocketInputStream.java:121)
      at java.io.DataInputStream.readFully(DataInputStream.java:195)
      at java.io.DataInputStream.readFully(DataInputStream.java:169)
      at net.sourceforge.jtds.jdbc.SharedSocket.readPacket(SharedSocket.java:842)
      at net.sourceforge.jtds.jdbc.SharedSocket.getNetPacket(SharedSocket.java:723)
      at net.sourceforge.jtds.jdbc.ResponseStream.getPacket(ResponseStream.java:466)
      at net.sourceforge.jtds.jdbc.ResponseStream.read(ResponseStream.java:103)
      at net.sourceforge.jtds.jdbc.ResponseStream.peek(ResponseStream.java:88)
      at net.sourceforge.jtds.jdbc.TdsCore.wait(TdsCore.java:3932)
      at net.sourceforge.jtds.jdbc.TdsCore.executeSQL(TdsCore.java:1046)
      ... 16 more
  </code></pre>
  
  <p><strong>Update :</strong></p>
  
  <p>My first code :</p>
  
  <pre><code>Session session = getSessionfactory().openSession();
  session.beginTransaction();
  
  ArrayList&lt;Object[]&gt; results = null;
  try {
      StringBuilder sb = new StringBuilder();
      sb.append("select p from person p ");
      sb.append("where CONTAINS(p.name , :myName) ");
  
      Query q = session.createSQLQuery(sb.toString());
      String myName = "Bob Jones";
      q.setString("myName", "*" + myName + "*");  
  
      results = (ArrayList&lt;Object[]&gt;) q.list();
  
  } catch (Exception e) {
      logger.error("Error : ", e);
  } finally {
      session.close();
  }
  </code></pre>
  
  <p>It doesn't work, <a href="https://stackoverflow.com/questions/14106239/how-to-use-the-named-parameters-with-contains">to fix it</a>
  this is the 2nd version :</p>
  
  <pre><code>Session session = getSessionfactory().openSession();
  session.beginTransaction();
  
  ArrayList&lt;Object[]&gt; results = null;
  try {
      StringBuilder sb = new StringBuilder();
      sb.append("select p from person p ");
      sb.append("where CONTAINS(p.name , :myName) ");
  
      Query q = session.createSQLQuery(sb.toString());
      String myName = "Bob Jones";
      q.setString("myName", "\"*" + myName + "*\""); 
  
      results = (ArrayList&lt;Object[]&gt;) q.list();
  
  } catch (Exception e) {
      logger.error("Error : ", e);
  } finally {
      session.close();
  }
  </code></pre>
  
  <p>Trying to run the 2nd version, I have the error above.</p>