0
votes

I have copied the jar file in sqoop/lib folder and the commands which i was using in sqoop is :

bin/sqoop import --connect jdbc:mysql://localhost:3306/sqoop --username root --password admin --table cities

Error Message :

14/06/21 08:44:44 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:772) 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:65) 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)

3

3 Answers

0
votes

you need to add the mysql-connector jar file to sqoop/lib folder to access the mysql database. and then execute your sqoop command.

download link : http://mvnrepository.com/artifact/mysql/mysql-connector-java/5.1.6

0
votes

Download mysql-connector jar from this link. Extract and copy the mysql-connector-java-5.1.46.jar file to $SQOOP_HOME/lib/ directory. Copy the same jar to lib wich is present in hdfs , if sqoop is using with hdfs.

0
votes

Try to add this option

--driver com.mysql.jdbc.Driver

also make sure you have run the below commands

% mysql -u root -p
Enter password:
mysql> GRANT ALL PRIVILEGES ON sqoop.* TO ''@'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> quit;
Bye