sqoop 工具报错:No columns to generate for ClassWriter报错真实原因

今天遇到这个错误,查了一下网上的答案五花八门,分析对比后结果发现,这个报错其实不是真正的报错。只是这段话刚好是报错代码的最后面,所以才被误以为这是一个独立的报错,这只是一类错误的统称,其实有很多不同的错误都会导致出现这个代码。

 java.io.IOException: No columns to generate for ClassWriter

比如:
(1)由于mysql驱动mysql-connector-java.jar的旧版本bug导致,或者oracal的驱动
(2)数据库的IP/用户名/密码/数据库名称 错误导致连接不上
(3)sqoop export时,没有在目的库建好表
(4)等等
大家要看清楚,自己的错到底是什么错。

贴上自己的报错:

19/05/29 16:32:20 INFO sqoop.Sqoop: Running Sqoop version: 
19/05/29 16:32:20 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
19/05/29 16:32:20 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
19/05/29 16:32:20 INFO tool.CodeGenTool: Beginning code generation
19/05/29 16:32:21 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM `mid_yyts_report_result` AS t LIMIT 1
19/05/29 16:32:21 ERROR manager.SqlManager: Error executing statement: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'yyts.mid_yyts_report_result' doesn't exist
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'yyts.mid_yyts_report_result' doesn't exist
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:408)
	at com.mysql.jdbc.Util.getInstance(Util.java:383)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1062)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4208)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4140)
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2597)
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2758)
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2826)
	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2082)
	at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2212)
	at org.apache.sqoop.manager.SqlManager.execute(SqlManager.java:750)
	at org.apache.sqoop.manager.SqlManager.execute(SqlManager.java:759)
	at org.apache.sqoop.manager.SqlManager.getColumnInfoForRawQuery(SqlManager.java:269)
	at org.apache.sqoop.manager.SqlManager.getColumnTypesForRawQuery(SqlManager.java:240)
	at org.apache.sqoop.manager.SqlManager.getColumnTypes(SqlManager.java:226)
	at org.apache.sqoop.manager.ConnManager.getColumnTypes(ConnManager.java:295)
	at org.apache.sqoop.orm.ClassWriter.getColumnTypes(ClassWriter.java:1773)
	at org.apache.sqoop.orm.ClassWriter.generate(ClassWriter.java:1578)
	at org.apache.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:96)
	at org.apache.sqoop.tool.ExportTool.exportTable(ExportTool.java:64)
	at org.apache.sqoop.tool.ExportTool.run(ExportTool.java:100)
	at org.apache.sqoop.Sqoop.run(Sqoop.java:143)
	at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
	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)
19/05/29 16:32:21 ERROR tool.ExportTool: Encountered IOException running export job: java.io.IOException: No columns to generate for ClassWriter

找一找可以看到,其实报错中间有一句:

Table 'yyts.mid_yyts_report_result' doesn't exist

这才是执行代码真正的错误。所以,大家看自己看自己的报错呀,不要遇到报错就翻到最后一行,然后复制粘贴去百度,错误都没定位出来,怎么解决bug呢?

你可能感兴趣的:(hive,sqoop,hive)