【問題排查】sqoop將mysql匯入hive異常:No suitable driver

Echo_Jiang發表於2022-05-06

問題描述

安裝Sqoop後, 將mysql匯入hive異常: No suitable driver found for jdbc:mysql:/192.168.5.102:3306/test


具體報錯如下



[root@hx002 ~]#  sqoop export --connect jdbc :mysql:/192.168.5.102:3306/test --username root --password root1234 --table ods_test_stu --export-dir /user/hive/warehouse/ods_test_stu --fields-terminated-by '\001'
Warning: /opt/module/sqoop-1.4.7.bin__hadoop-2.6.0/../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.7.bin__hadoop-2.6.0/../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.7.bin__hadoop-2.6.0/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
Warning: /opt/module/sqoop-1.4.7.bin__hadoop-2.6.0/../zookeeper does not exist! Accumulo imports will fail.
Please set $ZOOKEEPER_HOME to the root of your Zookeeper installation.
22/05/05 10:54:34 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7
22/05/05 10:54:34 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
22/05/05 10:54:34 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
22/05/05 10:54:35 INFO tool.CodeGenTool: Beginning code generation
22/05/05 10:54:35 ERROR manager.SqlManager : Error executing statement: java.sql.SQLException: No suitable driver found for jdbc:mysql:/192.168.5.102:3306/test
java.sql.SQLException: No suitable driver found for jdbc:mysql:/192.168.5.102:3306/test
        at java.sql.DriverManager.getConnection(DriverManager.java:689)
        at java.sql.DriverManager.getConnection(DriverManager.java:247)
        at org.apache.sqoop.manager.SqlManager.makeConnection(SqlManager.java:904)
        at org.apache.sqoop.manager.GenericJdbcManager.getConnection(GenericJdbcManager.java:59)
        at org.apache.sqoop.manager.SqlManager.execute(SqlManager.java:763)
        at org.apache.sqoop.manager.SqlManager.execute(SqlManager.java:786)
        at org.apache.sqoop.manager.SqlManager.getColumnInfoForRawQuery(SqlManager.java:289)
        at org.apache.sqoop.manager.SqlManager.getColumnTypesForRawQuery(SqlManager.java:260)
        at org.apache.sqoop.manager.SqlManager.getColumnTypes(SqlManager.java:246)
        at org.apache.sqoop.manager.ConnManager.getColumnTypes(ConnManager.java:327)
        at org.apache.sqoop.orm.ClassWriter.getColumnTypes(ClassWriter.java:1872)
        at org.apache.sqoop.orm.ClassWriter.generate(ClassWriter.java:1671)
        at org.apache.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:106)
        at org.apache.sqoop.tool.ExportTool.exportTable(ExportTool.java:63)
        at org.apache.sqoop.tool.ExportTool.run(ExportTool.java:99)
        at org.apache.sqoop.Sqoop.run(Sqoop.java:147)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
        at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:183)
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:234)
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:243)
        at org.apache.sqoop.Sqoop.main(Sqoop.java:252)
22/05/05 10:54:35 ERROR tool.ExportTool: Encountered IOException running export job:
java.io.IOException : No columns to generate for ClassWriter
        at org.apache.sqoop.orm.ClassWriter.generate(ClassWriter.java:1677)
        at org.apache.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:106)
        at org.apache.sqoop.tool.ExportTool.exportTable(ExportTool.java:63)
        at org.apache.sqoop.tool.ExportTool.run(ExportTool.java:99)
        at org.apache.sqoop.Sqoop.run(Sqoop.java:147)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
        at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:183)
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:234)
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:243)
        at org.apache.sqoop.Sqoop.main(Sqoop.java:252)


問題排查與解析


錯誤排查,連線URL格式出現問題:
錯誤輸入:
[root@hx002 ~]#  sqoop export --connect jdbc :mysql:/192.168.5.102:3306/test   --username root --password root1234 --table ods_test_stu --export-dir /user/hive/warehouse/ods_test_stu --fields-terminated-by '\001'
修改後
sqoop export --connect jdbc: mysql://192.168.5.102:3306/test --username root --password root1234 --table ods_test_stu --export-dir /user/hive/warehouse/ods_test_stu --fields-terminated-by '\001'

問題延展


今天編碼出現了No suitable driver found for jdbc,找遍了網上的資料,基本上都說是三個問題:
    一是:連線URL格式出現了問題(Connection conn=DriverManager.getConnection("jdbc: ")
    二是:驅動字串出錯(com.mysql.jdbc.Driver)
    三是Classpath中沒有加入合適的mysql_jdbc驅動

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/70017085/viewspace-2892484/,如需轉載,請註明出處,否則將追究法律責任。

相關文章