use of com.alibaba.datax.plugin.writer.adswriter.AdsException in project DataX by alibaba.
the class AdsHelper method checkLoadDataJobStatusWithRetry.
private String checkLoadDataJobStatusWithRetry(final String jobId) throws AdsException {
try {
Class.forName("com.mysql.jdbc.Driver");
final String finalAdsUrl = this.adsURL;
final String finalSchema = this.schema;
final Long finalSocketTimeout = this.socketTimeout;
final String suffix = this.suffix;
return RetryUtil.executeWithRetry(new Callable<String>() {
@Override
public String call() throws Exception {
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
try {
String url = AdsUtil.prepareJdbcUrl(finalAdsUrl, finalSchema, finalSocketTimeout, suffix);
Properties connectionProps = new Properties();
connectionProps.put("user", userName);
connectionProps.put("password", password);
connection = DriverManager.getConnection(url, connectionProps);
statement = connection.createStatement();
String sql = "select state from information_schema.job_instances where job_id like '" + jobId + "'";
rs = statement.executeQuery(sql);
String state = null;
while (DBUtil.asyncResultSetNext(rs)) {
state = rs.getString(1);
}
return state;
} finally {
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
// Ignore exception
}
}
if (statement != null) {
try {
statement.close();
} catch (SQLException e) {
// Ignore exception
}
}
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
// Ignore exception
}
}
}
}
}, 3, 1000L, true);
} catch (Exception e) {
throw new AdsException(AdsException.OTHER, e.getMessage(), e);
}
}
Aggregations