Sqoop问题已解决:连接数据库报错 javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disab

在学习有关大数据的知识中,使用sqoop连接数据库发生异常,现在问题已解决,做一下经验总结。

以下是我遇到的错误:

1.运行报错java.lang.RuntimeException: Could not load db driver class: com.mysql.jdbc.Driver:

[king@Hadoop102 lib]$ sqoop list-databases --connect jdbc:mysql://hadoop102:3306 --username root --password 123456
Warning: /opt/module/sqoop-1.4.6/../hbase does not exist! HBase imports will fail.
Please set $HBASE_HOME to the root of your HBase installation.
Warning: /opt/module/sqoop-1.4.6/../hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
Warning: /opt/module/sqoop-1.4.6/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
2025-04-01 16:24:28,775 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6
2025-04-01 16:24:28,804 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
2025-04-01 16:24:28,893 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
2025-04-01 16:24:28,894 ERROR sqoop.Sqoop: Got exception running Sqoop: java.lang.RuntimeException: Could not load db driver class: com.mysql.jdbc.Driver
java.lang.RuntimeException: Could not load db driver class: com.mysql.jdbc.Driver
    at org.apache.sqoop.manager.SqlManager.makeConnection(SqlManager.java:856)
    at org.apache.sqoop.manager.GenericJdbcManager.getConnection(GenericJdbcManager.java:52)
    at org.apache.sqoop.manager.CatalogQueryManager.listDatabases(CatalogQueryManager.java:57)
    at org.apache.sqoop.tool.ListDatabasesTool.run(ListDatabasesTool.java:49)
    at org.apache.sqoop.Sqoop.run(Sqoop.java:143)
    at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:76)
    at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:179)
    at org.apache.sqoop.Sqoop.runTool(Sqoop.java:218)
    at org.apache.sqoop.Sqoop.runTool(Sqoop.java:227)
    at org.apache.sqoop.Sqoop.main(Sqoop.java:236)
 

解决办法:提示我没有监测到driver,但是我已经把驱动放到/lib目录中,检查了一下版本发现mysql-connector版本是5.1.37

2.于是替换版本为mysql-connector-java-5.1.47,此时又报错误:

2025-04-01 16:46:36,952 ERROR manager.CatalogQueryManager: Failed to list databases
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Caused by: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)

我又替换了mysql-connector版本为5.1.17,此时运行成功

总结:我的sqoop版本为1.4.6,在连接数据库有时会失败,可以尝试更换连接驱动的版本号,多试几个版本

附驱动版本链接:

5.1.6  :https://pan.baidu.com/s/12tgTFoZzf8sbkzJy_5-jng?pwd=7777
5.1.17:https://pan.baidu.com/s/1XTn9zTkicLPWHEMjN15HkA?pwd=7777
5.1.47:https://pan.baidu.com/s/1OErAYRP0iYfxvo0mzWlBYg?pwd=7777
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值