public class MysqlAutoIncrementHelper implements AutoIncrementHelper, ThreadSafe {
public Object getPostValue( Configuration tableConf, Configuration columnConf, Configuration modeConf,
Connection conn, Statement stmt, Request request ) throws SQLException, ConfigurationException {
Integer id = null;
/*
// if mysql did support callable statements ... i'm not sure what what would go here, maybe:
CallableStatement callStmt = conn.prepareCall("? = {CALL LAST_INSERT_ID()}");
callStmt.registerOutParameter(1, Types.INTEGER);
ResultSet resultSet = callStmt.executeQuery();
*/
PreparedStatement pstmt = conn.prepareStatement("SELECT LAST_INSERT_ID()");
ResultSet resultSet = pstmt.executeQuery();
while ( resultSet.next() ) {
id = new Integer(resultSet.getInt(1));
}
resultSet.close();
return id;
}