Я пытаюсь выполнить пакетную вставку для пары записей, используя PreparedStatement.Тем не менее, я продолжаю получать ложь всякий раз, когда я вызываю следующий на моем ResultSet
public ResultSet insert_into_batch(ArrayList<Movie> values) throws SQLException
{
conn.setAutoCommit(false);
ArrayList<String> added = new ArrayList<String>();
String stmt = "INSERT INTO movies (id,title,year,director) VALUES (?,?,?,?)";
PreparedStatement psInsertRecord = conn.prepareStatement(stmt, Statement.RETURN_GENERATED_KEYS);
for (Movie movie : values)
{
if (!added.contains(movie.getId())) {
added.add(movie.getId());
psInsertRecord.setString(1, movie.getId());
psInsertRecord.setString(2, movie.getTitle());
psInsertRecord.setInt(3, movie.getYear());
psInsertRecord.setString(4, movie.getDirector());
psInsertRecord.addBatch();
}
}
psInsertRecord.executeBatch();
conn.commit();
conn.setAutoCommit(true);
return psInsertRecord.getGeneratedKeys();
}