中断问题和datax中自带的MySQL jar包版本有关,更换后即可。
背景:有个需求需要把服务器上的mysql业务库数据同步到另一台服务器上,我选择了datax来做批量同步操作。
现象:java批量执行的代码写好后,在自己电脑(win10)执行没问题,换了一台电脑(也是windows server 2019),报以下错误:
// 执行以下java命令(批量同步数据)
java -cp C:\xxx\data_sync\datasync-1.0-SNAPSHOT.jar com.xxx.Main C:\xxx\data_sync\tables.txt "sap"
// 打印以下日志后不再输出其他任何日志
2023-10-16 16:45:51.317 [job-0] INFO OriginalConfPretreatmentUtil - table:[table_001] all columns:[ id,type,name,visible,ext,gmt_create,gmt_modified ].
于是把java中执行datax的指令(python命令)提出来单独执行,可以执行成功,但会打印以下异常(该异常不影响执行成功)
Mon Oct 16 16:45:51 GMT+08:00 2023 WARN: Establishing SSL connection without server's identity verification is not recommended.
According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set.
For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'.
You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server
certificate verification.
WARN: Caught while disconnecting...
EXCEPTION STACK TRACE: ** BEGIN NESTED EXCEPTION ** javax.net.ssl.SSLException MESSAGE: closing inbound before receiving peer's close_notify STACKTRACE: javax.net.ssl.SSLException: closing inbound before receiving peer's close_notify at sun.security.ssl.Alert.createSSLException(Alert.java:133) at sun.security.ssl.Alert.createSSLException(Alert.java:117) at sun.security.ssl.TransportContext.fatal(TransportContext.java:340) at sun.security.ssl.TransportContext.fatal(TransportContext.java:296) at sun.security.ssl.TransportContext.fatal(TransportContext.java:287) at sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:737) at sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:716) at com.mysql.jdbc.MysqlIO.quit(MysqlIO.java:2241)
解决方案:根据这些异常信息,有两种解决方案:
1.连接数据库的Jdbc URL后面添加useSSL=false,如jdbc:mysql://xxx.xxx.xxx.xxx:3306/erp?useUnicode=true&characterEncoding=UTF-8&useSSL=false
我的是需要SSL加密连接的,已经配置了useSSL=true,所以这个方案不合适我的场景。
2.连接数据库的驱动版本可能有问题,需要更换驱动版本。
我把datax\plugin\reader\mysqlreader\libs和datax\plugin\writer\mysqlwriter\libs中mysql驱动jar,从mysql-connector-java-5.1.39.jar更换成mysql-connector-java-5.1.47.jar,不行,然后更换成mysql-connector-java-5.1.48.jar,问题解决,不再卡住。
标签:java,sun,xxx,表时,atax,ssl,mysql,security From: https://www.cnblogs.com/atai/p/17768068.html