public void testBug20687() throws Exception {
  if (versionMeetsMinimum(5,0)) {
    createTable("testBug20687","(field1 int)");
    Connection poolingConn=null;
    Properties props=new Properties();
    props.setProperty("cachePrepStmts","true");
    props.setProperty("useServerPrepStmts","true");
    PreparedStatement pstmt1=null;
    PreparedStatement pstmt2=null;
    try {
      poolingConn=getConnectionWithProps(props);
      pstmt1=poolingConn.prepareStatement("SELECT field1 FROM testBug20687");
      this.rs=pstmt1.executeQuery();
      pstmt1.close();
      pstmt2=poolingConn.prepareStatement("SELECT field1 FROM testBug20687");
      this.rs=pstmt2.executeQuery();
      assertTrue(pstmt1 == pstmt2);
      pstmt2.close();
    }
  finally {
      if (pstmt1 != null) {
        pstmt1.close();
      }
      if (pstmt2 != null) {
        pstmt2.close();
      }
      if (poolingConn != null) {
        poolingConn.close();
      }
    }
  }
}

public void testBug20687 ( ) throws Exception { if ( versionMeetsMinimum ( 5 , 0 ) ) { createTable ( "testBug20687" , "(field1 int)" ) ; Connection poolingConn = null ; Properties props = new Properties ( ) ; props . setProperty ( "cachePrepStmts" , "true" ) ; props . setProperty ( "useServerPrepStmts" , "true" ) ; PreparedStatement pstmt1 = null ; PreparedStatement pstmt2 = null ; try { poolingConn = getConnectionWithProps ( props ) ; pstmt1 = poolingConn . prepareStatement ( "SELECT field1 FROM testBug20687" ) ; this . rs = pstmt1 . executeQuery ( ) ; pstmt1 . close ( ) ; pstmt2 = poolingConn . prepareStatement ( "SELECT field1 FROM testBug20687" ) ; this . rs = pstmt2 . executeQuery ( ) ; assertTrue ( pstmt1 == pstmt2 ) ; pstmt2 . close ( ) ; } finally { if ( pstmt1 != null ) { pstmt1 . close ( ) ; } if ( pstmt2 != null ) { pstmt2 . close ( ) ; } if ( poolingConn != null ) { poolingConn . close ( ) ; } } } }
fixes bug # 20687 - can ' t pool server - side prepared statements , exception raised when re - using them .
