for (int i = 0; i < getCacheSize(); i++) {
stmt.executeUpdate("insert into " + getIncrementerName() + " (" + getDummyName() + ") values(null)");
ResultSet rs = stmt.executeQuery("select IDENTITY_VAL_LOCAL() from " + getIncrementerName());
try {
if (!rs.next()) {
throw new DataAccessResourceFailureException("IDENTITY_VAL_LOCAL() failed after executing an update");
}
this.valueCache[i] = rs.getLong(1);
}
finally {
JdbcUtils.closeResultSet(rs);
}
}
long maxValue = this.valueCache[(this.valueCache.length - 1)];
stmt.executeUpdate("delete from " + getIncrementerName() + " where " + getColumnName() + " < " + maxValue);
}
catch (SQLException ex) {
throw new DataAccessResourceFailureException("Could not obtain IDENTITY value", ex);
}
finally {
JdbcUtils.closeStatement(stmt);
DataSourceUtils.releaseConnection(con, getDataSource());
}