1、Flink 写入 mysql 失败
问题背景:Flink处理数据写入mysql中,出现各类报错。
1.1
问题描述
Caused by: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
解决方案
# 设置url: useSSL=false
jdbc:mysql://127.0.0.1:3306/test?serverTimezone=GMT%2B8&useUnicode=true&useSSL=false&characterEncoding=utf8&autoReconnect=true&useAffectedRows=true&allowMultiQueries=true
1.2
问题描述
Exception in thread "main" org.apache.flink.runtime.client.JobExecutionException: Job execution failed.
Caused by: org.apache.flink.streaming.runtime.tasks.AsynchronousException: Caught exception while processing timer.
Caused by: java.sql.SQLException: Column count doesn't match value count at row 1
解决方案
# 因为设置了主键自增,所以可以不指定主键,但需要指定列名
# 方法1
insert into userInfo values(null,'jack',20);
# 方法2
insert into userInfo values(0,'jack',20);
# 方法3
insert into userInfo(name,age) values('jack',20);