public void testBug18041() throws Exception {
  if (versionMeetsMinimum(4,1)) {
    createTable("testBug18041","(`a` tinyint(4) NOT NULL, `b` char(4) default NULL)");
    Properties props=new Properties();
    props.setProperty("jdbcCompliantTruncation","true");
    props.setProperty("useServerPrepStmts","true");
    Connection truncConn=null;
    PreparedStatement stm=null;
    try {
      truncConn=getConnectionWithProps(props);
      stm=truncConn.prepareStatement("insert into testBug18041 values (?,?)");
      stm.setInt(1,1000);
      stm.setString(2,"nnnnnnnnnnnnnnnnnnnnnnnnnnnnnn");
      stm.executeUpdate();
      fail("Truncation exception should have been thrown");
    }
 catch (    DataTruncation truncEx) {
    }
 finally {
      if (truncConn != null) {
        truncConn.close();
      }
    }
  }
}

public void testBug18041 ( ) throws Exception { if ( versionMeetsMinimum ( 4 , 1 ) ) { createTable ( "testBug18041" , "(`a` tinyint(4) NOT NULL, `b` char(4) default NULL)" ) ; Properties props = new Properties ( ) ; props . setProperty ( "jdbcCompliantTruncation" , "true" ) ; props . setProperty ( "useServerPrepStmts" , "true" ) ; Connection truncConn = null ; PreparedStatement stm = null ; try { truncConn = getConnectionWithProps ( props ) ; stm = truncConn . prepareStatement ( "insert into testBug18041 values (?,?)" ) ; stm . setInt ( 1 , 1000 ) ; stm . setString ( 2 , "nnnnnnnnnnnnnnnnnnnnnnnnnnnnnn" ) ; stm . executeUpdate ( ) ; fail ( "Truncation exception should have been thrown" ) ; } catch ( DataTruncation truncEx ) { } finally { if ( truncConn != null ) { truncConn . close ( ) ; } } } }
tests fix for bug # 18041 - server - side prepared statements don ' t cause truncation exceptions to be thrown .
