Skip to content

Commit 1b1a1ce

Browse files
committed
Update mysql jdbc driver
1 parent 368907f commit 1b1a1ce

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

adswriter/src/main/java/com/alibaba/datax/plugin/writer/adswriter/insert/AdsInsertProxy.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
import com.alibaba.datax.plugin.writer.adswriter.util.AdsUtil;
1414
import com.alibaba.datax.plugin.writer.adswriter.util.Constant;
1515
import com.alibaba.datax.plugin.writer.adswriter.util.Key;
16-
import com.mysql.jdbc.JDBC4PreparedStatement;
1716

17+
import com.mysql.cj.jdbc.ServerPreparedStatement;
1818
import org.apache.commons.lang3.StringUtils;
1919
import org.apache.commons.lang3.tuple.Pair;
2020
import org.slf4j.Logger;
@@ -251,7 +251,7 @@ public int compare(Record record1, Record record2) {
251251

252252
private void doBatchRecord(final List<Record> buffer, final String mode) throws SQLException {
253253
List<Class<?>> retryExceptionClasss = new ArrayList<Class<?>>();
254-
retryExceptionClasss.add(com.mysql.jdbc.exceptions.jdbc4.CommunicationsException.class);
254+
retryExceptionClasss.add(com.mysql.cj.jdbc.exceptions.CommunicationsException.class);
255255
retryExceptionClasss.add(java.net.SocketException.class);
256256
try {
257257
RetryUtil.executeWithRetry(new Callable<Boolean>() {
@@ -333,7 +333,7 @@ private void doBatchRecordDml(List<Record> buffer, String mode) throws Exception
333333

334334
private void doOneRecord(List<Record> buffer, final String mode) {
335335
List<Class<?>> retryExceptionClasss = new ArrayList<Class<?>>();
336-
retryExceptionClasss.add(com.mysql.jdbc.exceptions.jdbc4.CommunicationsException.class);
336+
retryExceptionClasss.add(com.mysql.cj.jdbc.exceptions.CommunicationsException.class);
337337
retryExceptionClasss.add(java.net.SocketException.class);
338338
for (final Record record : buffer) {
339339
try {
@@ -400,7 +400,7 @@ private void doOneRecordDml(Record record, String mode) throws Exception {
400400

401401
private boolean isRetryable(Throwable e) {
402402
Class<?> meetExceptionClass = e.getClass();
403-
if (meetExceptionClass == com.mysql.jdbc.exceptions.jdbc4.CommunicationsException.class) {
403+
if (meetExceptionClass == com.mysql.cj.jdbc.exceptions.CommunicationsException.class) {
404404
return true;
405405
}
406406
if (meetExceptionClass == java.net.SocketException.class) {
@@ -437,7 +437,7 @@ private String generateDmlSql(Connection connection, Record record, String mode)
437437
int columnSqltype = this.userConfigColumnsMetaData.get(columnName).getLeft();
438438
prepareColumnTypeValue(statement, columnSqltype, record.getColumn(preparedParamsIndex), i, columnName);
439439
}
440-
sql = ((JDBC4PreparedStatement) statement).asSql();
440+
sql = ((ServerPreparedStatement) statement).asSql();
441441
DBUtil.closeDBResources(statement, null);
442442
} else {
443443
sqlSb.append(this.deleteSqlPrefix);
@@ -468,7 +468,7 @@ private String generateDmlSql(Connection connection, Record record, String mode)
468468
prepareColumnTypeValue(statement, columnSqlType, record.getColumn(primaryKeyInUserConfigIndex), i, columnName);
469469
i++;
470470
}
471-
sql = ((JDBC4PreparedStatement) statement).asSql();
471+
sql = ((ServerPreparedStatement) statement).asSql();
472472
DBUtil.closeDBResources(statement, null);
473473
}
474474
return sql;

0 commit comments

Comments
 (0)