public static int createWithIdGeneration(Connection connection,String rawSqlQuery,Object... parameters) throws SQLException {
  PreparedStatement stmt=null;
  ResultSet rs=null;
  try {
    stmt=connection.prepareStatement(rawSqlQuery,Statement.RETURN_GENERATED_KEYS);
    for (int index=0; index < parameters.length; index++) {
      JdbcUtils.bindParameter(stmt,index + 1,parameters[index]);
    }
    stmt.executeUpdate();
    rs=stmt.getGeneratedKeys();
    rs.next();
    return rs.getInt(1);
  }
  finally {
    JdbcUtils.closeResultSet(rs);
    JdbcUtils.closeStatement(stmt);
  }
}

public static int createWithIdGeneration ( Connection connection , String rawSqlQuery , Object ... parameters ) throws SQLException { PreparedStatement stmt = null ; ResultSet rs = null ; try { stmt = connection . prepareStatement ( rawSqlQuery , Statement . RETURN_GENERATED_KEYS ) ; for ( int index = 0 ; index < parameters . length ; index ++ ) { JdbcUtils . bindParameter ( stmt , index + 1 , parameters [ index ] ) ; } stmt . executeUpdate ( ) ; rs = stmt . getGeneratedKeys ( ) ; rs . next ( ) ; return rs . getInt ( 1 ) ; } finally { JdbcUtils . closeResultSet ( rs ) ; JdbcUtils . closeStatement ( stmt ) ; } }
insert one row into database with the auto incremental id returned .
