【Kettle-ERROR】ETL工具-Kettle连接MySQL报错及解决方案

11 篇文章 0 订阅
10 篇文章 106 订阅

1.驱动问题

在kettle中新建mysql连接时,一般都选择Native(JDBC)方法,这时需要下载与MySQL版本对应的connector连接jar包,放在kettle安装目录的 data-integration\lib下;
低版本的MySQL数据库按这种方法一般没问题,但是mysql 8.0以上connector已经不再支持这个包名,所以会出现已经将mysql-connector-java-8.0.xx.jar包拷贝到lib目录下,但还是报错说找不到驱动。
报错如下:

错误连接数据库 [tcc] : org.pentaho.di.core.exception.KettleDatabaseException:
Error occurred while trying to connect to the database
Driver class ‘org.gjt.mm.mysql.Driver’ could not be found, make sure the ‘MySQL’ driver (jar file) is installed.

这种方法不能指定驱动类型,kettle默认使用的驱动类型是org.gjt.mm.mysql.Driver;

解决方法

这时可以采用JNDI方法设置kettle使用com.mysql.cj.jdbc.Driver作为连接MySQL的驱动。
具体设置如下:
将mysql-connector-java-8.0.xx.jar包拷贝到lib目录下,
然后在data-integration\simple-jndi目录下的jdbc.properties文件中新建JNDI配置:

注意:代码中的中文部分改成你要连接的MySQL数据库相关配置

mysql_test/type=javax.sql.DataSource
mysql_test/driver=com.mysql.cj.jdbc.Driver
mysql_test/url=jdbc:mysql://填写你的主机名:3306/填写你的数据库名?useUnicode=true&characterEncoding=utf-8&disableMariaDbDriver
mysql_test/user=填上你的MySQL数据库登录用户名
mysql_test/password=填上你的MySQL数据库登录密码

原文链接:https://blog.csdn.net/zougen/article/details/84975410

2.时区冲突问题

按照上述方法设置后一般能正常连接,但是有些也会报如下错误:

java.sql.SQLException: The server time zone value ‘�й���׼ʱ��’ is unrecognized or represents more than one time zone.
You must configure either the server or JDBC driver (via the ‘serverTimezone’ configuration property) to use a more specifc time zone value if you want to utilize time zone support.

解决方法

MySQL连接地址加个配置: &serverTimezone=UTC
还是上述data-integration\simple-jndi目录下的jdbc.properties文件中:
– 原来的设置

-- 原来的设置
mysql_test/url=jdbc:mysql://填写你的主机名:3306/填写你的数据库名?useUnicode=true&characterEncoding=utf-8&disableMariaDbDriver

– 修改后的设置

-- 修改后的设置
mysql_test/url=jdbc:mysql://填写你的主机名:3306/填写你的数据库名?useUnicode=true&characterEncoding=utf-8&disableMariaDbDriver&serverTimezone=UTC
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值