二百、Flink——Flink写入MySQL报错:Establishing SSL connection without server‘s identity verification is not r

一、目的

在尚硅谷学习用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

二百、Flink——Flink写入MySQL报错:Establishing SSL connection without server‘s identity verification is not r_第1张图片

三、解决措施

试了半天,发现是MySQL的SSL配置有问题,尚硅谷的代码有点小问题,MySQL的连接配置没有SSL

(一)尚硅谷原有代码

conn = DriverManager. getConnection ( "jdbc:mysql://localhost:3306/test" ,
"root" , "123456" );

(二)在自己项目里添加MySQL的SSL配置

connection = DriverManager.getConnection("jdbc:mysql://192.168.0.23:3306/test?useSSL=false&useUnicode=true&characterEncoding=UTF-8", "root", "hurys@123");

二百、Flink——Flink写入MySQL报错:Establishing SSL connection without server‘s identity verification is not r_第2张图片

(三)改好后运行IDEA项目

二百、Flink——Flink写入MySQL报错:Establishing SSL connection without server‘s identity verification is not r_第3张图片

运行成功,没有报错!

(四)在MySQL查验表中是否有数据

二百、Flink——Flink写入MySQL报错:Establishing SSL connection without server‘s identity verification is not r_第4张图片

MySQL中确实有数据写入,测试成功!

又解决了一个问题,宾果!

你可能感兴趣的:(Flink,flink,mysql)