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

SQOOP-1734: Port SQOOP-1725 to sqoop2 branch

(Abraham Elmahrek via Jarek Jarcec Cecho)
This commit is contained in:
Jarek Jarcec Cecho 2014-11-18 10:28:27 -08:00
parent 37a5552bab
commit dacf889c7d
2 changed files with 13 additions and 1 deletions

View File

@ -175,11 +175,14 @@ public void upgradeConnectorAndConfigs(MConnector mConnector, Connection conn) {
private void updateConnectorAndDeleteConfigs(MConnector mConnector, Connection conn) {
PreparedStatement updateConnectorStatement = null;
PreparedStatement deleteConfig = null;
PreparedStatement deleteConfigDirection = null;
PreparedStatement deleteInput = null;
try {
updateConnectorStatement = conn.prepareStatement(CommonRepositoryInsertUpdateDeleteSelectQuery.STMT_UPDATE_CONFIGURABLE);
deleteInput = conn.prepareStatement(CommonRepositoryInsertUpdateDeleteSelectQuery.STMT_DELETE_INPUTS_FOR_CONFIGURABLE);
deleteConfigDirection = conn.prepareStatement(CommonRepositoryInsertUpdateDeleteSelectQuery.STMT_DELETE_DIRECTIONS_FOR_CONFIGURABLE);
deleteConfig = conn.prepareStatement(CommonRepositoryInsertUpdateDeleteSelectQuery.STMT_DELETE_CONFIGS_FOR_CONFIGURABLE);
updateConnectorStatement.setString(1, mConnector.getUniqueName());
updateConnectorStatement.setString(2, mConnector.getClassName());
updateConnectorStatement.setString(3, mConnector.getVersion());
@ -190,15 +193,17 @@ private void updateConnectorAndDeleteConfigs(MConnector mConnector, Connection c
throw new SqoopException(CommonRepositoryError.COMMON_0035);
}
deleteInput.setLong(1, mConnector.getPersistenceId());
deleteConfigDirection.setLong(1, mConnector.getPersistenceId());
deleteConfig.setLong(1, mConnector.getPersistenceId());
deleteInput.executeUpdate();
deleteConfigDirection.executeUpdate();
deleteConfig.executeUpdate();
} catch (SQLException e) {
logException(e, mConnector);
throw new SqoopException(CommonRepositoryError.COMMON_0035, e);
} finally {
closeStatements(updateConnectorStatement, deleteConfig, deleteInput);
closeStatements(updateConnectorStatement, deleteConfig, deleteConfigDirection, deleteInput);
}
}

View File

@ -549,4 +549,11 @@ public class CommonRepositoryInsertUpdateDeleteSelectQuery {
public static final String STMT_SELECT_SQ_CONFIG_DIRECTIONS =
STMT_SELECT_SQ_CONFIG_DIRECTIONS_ALL + " WHERE "
+ COLUMN_SQ_CFG_DIR_CONFIG + " = ?";
// Delete the config directions for a connector
public static final String STMT_DELETE_DIRECTIONS_FOR_CONFIGURABLE =
"DELETE FROM " + TABLE_SQ_CONFIG_DIRECTIONS
+ " WHERE " + COLUMN_SQ_CFG_DIR_CONFIG
+ " IN (SELECT " + COLUMN_SQ_CFG_ID + " FROM " + TABLE_SQ_CONFIG
+ " WHERE " + COLUMN_SQ_CFG_CONFIGURABLE + " = ?)";
}