5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-16 17:00:53 +08:00

SQOOP-843: Generic JDBC connector is committing transaction on export with autoCommit on

(Jarcec Cecho via Cheolsoo Park)
This commit is contained in:
Cheolsoo Park 2013-01-30 15:23:36 -08:00
parent 92062d5343
commit eef227a5f9
2 changed files with 9 additions and 0 deletions

View File

@ -61,6 +61,14 @@ public ResultSet executeQuery(String sql) {
} }
} }
public void setAutoCommit(boolean autoCommit) {
try {
connection.setAutoCommit(autoCommit);
} catch (SQLException e) {
throw new SqoopException(GenericJdbcConnectorError.GENERIC_JDBC_CONNECTOR_0002, e);
}
}
public void executeUpdate(String sql) { public void executeUpdate(String sql) {
try { try {
Statement statement = connection.createStatement( Statement statement = connection.createStatement(

View File

@ -37,6 +37,7 @@ public void load(ImmutableContext context, ConnectionConfiguration connection, E
String username = connection.connection.username; String username = connection.connection.username;
String password = connection.connection.password; String password = connection.connection.password;
GenericJdbcExecutor executor = new GenericJdbcExecutor(driver, url, username, password); GenericJdbcExecutor executor = new GenericJdbcExecutor(driver, url, username, password);
executor.setAutoCommit(false);
String sql = context.getString(GenericJdbcConnectorConstants.CONNECTOR_JDBC_DATA_SQL); String sql = context.getString(GenericJdbcConnectorConstants.CONNECTOR_JDBC_DATA_SQL);
executor.beginBatch(sql); executor.beginBatch(sql);