5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-08 07:11:01 +08:00

SQOOP-1725: Sqoop2: Connector upgrade in 1.99.4 fails with delete configs

(Veena Basavaraj via Abraham Elmahrek)
This commit is contained in:
Abraham Elmahrek 2014-11-13 14:57:06 -08:00
parent fbdd940eb3
commit 05711d1411
2 changed files with 18 additions and 1 deletions

View File

@ -1294,11 +1294,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(STMT_UPDATE_CONFIGURABLE);
deleteInput = conn.prepareStatement(STMT_DELETE_INPUTS_FOR_CONFIGURABLE);
deleteConfigDirection = conn.prepareStatement(STMT_DELETE_DIRECTIONS_FOR_CONFIGURABLE);
deleteConfig = conn.prepareStatement(STMT_DELETE_CONFIGS_FOR_CONFIGURABLE);
updateConnectorStatement.setString(1, mConnector.getUniqueName());
updateConnectorStatement.setString(2, mConnector.getClassName());
updateConnectorStatement.setString(3, mConnector.getVersion());
@ -1309,15 +1312,17 @@ private void updateConnectorAndDeleteConfigs(MConnector mConnector, Connection c
throw new SqoopException(DerbyRepoError.DERBYREPO_0038);
}
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(DerbyRepoError.DERBYREPO_0038, e);
} finally {
closeStatements(updateConnectorStatement, deleteConfig, deleteInput);
closeStatements(updateConnectorStatement, deleteConfig, deleteConfigDirection, deleteInput);
}
}

View File

@ -628,6 +628,18 @@ public final class DerbySchemaInsertUpdateDeleteSelectQuery {
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 + " = ?)";
private DerbySchemaInsertUpdateDeleteSelectQuery() {