src/main/java/org/embulk/output/redshift/RedshiftOutputConnection.java in embulk-output-redshift-0.1.2 vs src/main/java/org/embulk/output/redshift/RedshiftOutputConnection.java in embulk-output-redshift-0.2.0
- old
+ new
@@ -28,15 +28,15 @@
{
Statement stmt = connection.createStatement();
try {
String sql = String.format("DROP TABLE IF EXISTS %s", quoteIdentifierString(tableName));
executeUpdate(stmt, sql);
- connection.commit();
+ commitIfNecessary(connection);
} catch (SQLException ex) {
// ignore errors.
// TODO here should ignore only 'table "XXX" does not exist' errors.
- connection.rollback();
+ SQLException ignored = safeRollback(connection, ex);
} finally {
stmt.close();
}
}
@@ -55,11 +55,11 @@
executeUpdate(stmt, sql);
} catch (SQLException ex) {
// ignore errors.
// TODO here should ignore only 'table "XXX" does not exist' errors.
// rollback or comimt is required to recover failed transaction
- connection.rollback();
+ SQLException ignored = safeRollback(connection, ex);
}
{
StringBuilder sb = new StringBuilder();
sb.append("ALTER TABLE ");
@@ -68,13 +68,12 @@
quoteIdentifierString(sb, toTable);
String sql = sb.toString();
executeUpdate(stmt, sql);
}
- connection.commit();
+ commitIfNecessary(connection);
} catch (SQLException ex) {
- connection.rollback();
- throw ex;
+ throw safeRollback(connection, ex);
} finally {
stmt.close();
}
}