I tried the following import command and i get the given error. GRANT ALL PRIVILEGES was giving warning so i created user. Please help



0
 CREATE USER abc@'192.168.199.130'
  IDENTIFIED BY 'abc' ;
  GRANT ALL PRIVILEGES
  ON *.*
  TO abc@'192.168.199.130';
  FLUSH PRIVILEGES;	






-----------------------------------------------------------------------------------
[cloudera@localhost sqoop]$ bin/sqoop import --connect jdbc:mysql://192.168.199.1/world --table city --username abc  -P --target-dir /user/cloudera/class-8/ev/sqoopOut1 -m 2
Enter password: 
17/04/17 12:45:52 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
17/04/17 12:45:52 INFO tool.CodeGenTool: Beginning code generation
17/04/17 12:46:14 ERROR manager.SqlManager: Error executing statement: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
	at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
	at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:346)
	at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2334)
	at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2371)
	at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2163)
	at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:794)
	at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
	at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:378)
	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
	at java.sql.DriverManager.getConnection(DriverManager.java:582)
	at java.sql.DriverManager.getConnection(DriverManager.java:185)
	at org.apache.sqoop.manager.SqlManager.makeConnection(SqlManager.java:801)
	at org.apache.sqoop.manager.GenericJdbcManager.getConnection(GenericJdbcManager.java:52)
	at org.apache.sqoop.manager.SqlManager.execute(SqlManager.java:660)
	at org.apache.sqoop.manager.SqlManager.execute(SqlManager.java:683)
	at org.apache.sqoop.manager.SqlManager.getColumnTypesForRawQuery(SqlManager.java:240)
	at org.apache.sqoop.manager.SqlManager.getColumnTypes(SqlManager.java:223)
	at org.apache.sqoop.manager.ConnManager.getColumnTypes(ConnManager.java:347)
	at org.apache.sqoop.orm.ClassWriter.getColumnTypes(ClassWriter.java:1277)
	at org.apache.sqoop.orm.ClassWriter.generate(ClassWriter.java:1089)
	at org.apache.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:96)
	at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:396)
	at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:502)
	at org.apache.sqoop.Sqoop.run(Sqoop.java:145)
	at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
	at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:181)
	at org.apache.sqoop.Sqoop.runTool(Sqoop.java:220)
	at org.apache.sqoop.Sqoop.runTool(Sqoop.java:229)
	at org.apache.sqoop.Sqoop.main(Sqoop.java:238)
Caused by: java.net.ConnectException: Connection timed out
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
	at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
	at java.net.Socket.connect(Socket.java:529)
	at java.net.Socket.connect(Socket.java:478)
	at java.net.Socket.<init>(Socket.java:375)
	at java.net.Socket.<init>(Socket.java:218)
	at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:254)
	at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:295)
	... 32 more
17/04/17 12:46:14 ERROR tool.ImportTool: Encountered IOException running import job: java.io.IOException: No columns to generate for ClassWriter
	at org.apache.sqoop.orm.ClassWriter.generate(ClassWriter.java:1095)
	at org.apache.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:96)
	at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:396)
	at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:502)
	at org.apache.sqoop.Sqoop.run(Sqoop.java:145)
	at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
	at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:181)
	at org.apache.sqoop.Sqoop.runTool(Sqoop.java:220)
	at org.apache.sqoop.Sqoop.runTool(Sqoop.java:229)
	at org.apache.sqoop.Sqoop.main(Sqoop.java:238)

 


2 Answer(s)


0

Hi Abhishek,

You need to specify the port number, by default it is 3306 for Mysql. Please check your port number and mention the same with the IP, for example:

[cloudera@localhost sqoop]$ bin/sqoop import --connect jdbc:mysql://192.168.199.1:3306/world --table city --username abc  -P --target-dir /user/cloudera/class-8/ev/sqoopOut1 -m 2

Please try the following and make sure you have mysql connection driver available in the sqoop library.

Hope this helps.

Thanks.


0

Hi Abhijit, 

I already tried that too with port no. but it is not working. I have mysql connector jar in sqoop. But the same error comes. May be it is a priviledge problem. If u can give a code other then grant priviledges it may help. Please Help. Thanks

Your Answer

Click on this code-snippet-icon icon to add code snippet.

Upload Files (Maximum image file size - 1.5 MB, other file size - 10 MB, total size - not more than 50 MB)

Email
Password