一、目的
在尚硅谷学习用Flink把数据写入MySQL数据库的项目中,运行报错 Establishing SSL connection without server's identity verification is not recommended.
二、报错详情
Wed Nov 01 19:47:24 CST 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.
23/11/01 19:47:24 ERROR StreamTask: Error during disposal of stream operator.
java.lang.NullPointerException
三、解决措施
试了半天,发现是MySQL的SSL配置有问题,尚硅谷的代码有点小问题,MySQL的连接配置没有SSL
(一)尚硅谷原有代码
(二)在自己项目里添加MySQL的SSL配置
connection = DriverManager.getConnection("jdbc:mysql://192.168.0.23:3306/test?useSSL=false&useUnicode=true&characterEncoding=UTF-8", "root", "hurys@123");
(三)改好后运行IDEA项目
运行成功,没有报错!
(四)在MySQL查验表中是否有数据
MySQL中确实有数据写入,测试成功!
又解决了一个问题,宾果!