|
13 | 13 | import com.alibaba.datax.plugin.writer.adswriter.util.AdsUtil; |
14 | 14 | import com.alibaba.datax.plugin.writer.adswriter.util.Constant; |
15 | 15 | import com.alibaba.datax.plugin.writer.adswriter.util.Key; |
16 | | -import com.mysql.jdbc.JDBC4PreparedStatement; |
17 | 16 |
|
| 17 | +import com.mysql.cj.jdbc.ServerPreparedStatement; |
18 | 18 | import org.apache.commons.lang3.StringUtils; |
19 | 19 | import org.apache.commons.lang3.tuple.Pair; |
20 | 20 | import org.slf4j.Logger; |
@@ -251,7 +251,7 @@ public int compare(Record record1, Record record2) { |
251 | 251 |
|
252 | 252 | private void doBatchRecord(final List<Record> buffer, final String mode) throws SQLException { |
253 | 253 | 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); |
255 | 255 | retryExceptionClasss.add(java.net.SocketException.class); |
256 | 256 | try { |
257 | 257 | RetryUtil.executeWithRetry(new Callable<Boolean>() { |
@@ -333,7 +333,7 @@ private void doBatchRecordDml(List<Record> buffer, String mode) throws Exception |
333 | 333 |
|
334 | 334 | private void doOneRecord(List<Record> buffer, final String mode) { |
335 | 335 | 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); |
337 | 337 | retryExceptionClasss.add(java.net.SocketException.class); |
338 | 338 | for (final Record record : buffer) { |
339 | 339 | try { |
@@ -400,7 +400,7 @@ private void doOneRecordDml(Record record, String mode) throws Exception { |
400 | 400 |
|
401 | 401 | private boolean isRetryable(Throwable e) { |
402 | 402 | Class<?> meetExceptionClass = e.getClass(); |
403 | | - if (meetExceptionClass == com.mysql.jdbc.exceptions.jdbc4.CommunicationsException.class) { |
| 403 | + if (meetExceptionClass == com.mysql.cj.jdbc.exceptions.CommunicationsException.class) { |
404 | 404 | return true; |
405 | 405 | } |
406 | 406 | if (meetExceptionClass == java.net.SocketException.class) { |
@@ -437,7 +437,7 @@ private String generateDmlSql(Connection connection, Record record, String mode) |
437 | 437 | int columnSqltype = this.userConfigColumnsMetaData.get(columnName).getLeft(); |
438 | 438 | prepareColumnTypeValue(statement, columnSqltype, record.getColumn(preparedParamsIndex), i, columnName); |
439 | 439 | } |
440 | | - sql = ((JDBC4PreparedStatement) statement).asSql(); |
| 440 | + sql = ((ServerPreparedStatement) statement).asSql(); |
441 | 441 | DBUtil.closeDBResources(statement, null); |
442 | 442 | } else { |
443 | 443 | sqlSb.append(this.deleteSqlPrefix); |
@@ -468,7 +468,7 @@ private String generateDmlSql(Connection connection, Record record, String mode) |
468 | 468 | prepareColumnTypeValue(statement, columnSqlType, record.getColumn(primaryKeyInUserConfigIndex), i, columnName); |
469 | 469 | i++; |
470 | 470 | } |
471 | | - sql = ((JDBC4PreparedStatement) statement).asSql(); |
| 471 | + sql = ((ServerPreparedStatement) statement).asSql(); |
472 | 472 | DBUtil.closeDBResources(statement, null); |
473 | 473 | } |
474 | 474 | return sql; |
|
0 commit comments