Support Questions
Find answers, ask questions, and share your expertise

Sqoop jdbc error

Sqoop jdbc error

Explorer

sqoop import --connect jdbc:mysql:///usr/lib/sqoop/lib/mysql-connector-java.jar --username root --table emp --m 1
/usr/hdp/3.1.0.0-78/hadoop/libexec/hadoop-functions.sh: line 2363: HADOOP_ORG.APACHE.SQOOP.SQOOP_USER: bad substitution
/usr/hdp/3.1.0.0-78/hadoop/libexec/hadoop-functions.sh: line 2458: HADOOP_ORG.APACHE.SQOOP.SQOOP_OPTS: bad substitution
19/08/28 11:40:53 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7
19/08/28 11:40:53 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
19/08/28 11:40:53 INFO tool.CodeGenTool: Beginning code generation
19/08/28 11:40:53 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:875)
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.ImportTool.importTable(ImportTool.java:501)
at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:628)
at org.apache.sqoop.Sqoop.run(Sqoop.java:147)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:76)
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)

13 REPLIES 13

Re: Sqoop jdbc error

Super Mentor

@Manoj690 

 

You will need to make sure that  the "mysql-connector-java.jar"  is placed inside the "/usr/hdp/sqoop-client/lib" directory.

Also your SQOOP command seems to have incorrect mysql JDBC URL is not in correct format "jdbc:mysql://xxxxx:3306/dbname"

 

 

# sqoop import --connect jdbc:mysql://xxxxx:3306/dbname --username root --password XXXXXXXXX --table emp --m 1

 

 

 

Re: Sqoop jdbc error

Explorer

i places mysql jdbc connectors in sqoop/lib. still it shows same error. how can i cjeck that drivers are working or not. 

 

and also XXXXX:3306 means host name right?

Re: Sqoop jdbc error

Super Mentor

@Manoj690 
Yes, in the " jdbc:mysql://xxxxx:3306/dbname"    DB url "xxxxx" is MySQL Server hostname and the "dbname" will be the database which you are trying to connect inside MySQL.

Re: Sqoop jdbc error

Explorer

ERROR manager.SqlManager: Error executing statement: java.sql.SQLException: Access denied for user 'root'@'hostname' (using password: NO)

Re: Sqoop jdbc error

Super Mentor

@Manoj690 

 

As your latest error is 

ERROR manager.SqlManager: Error executing statement: java.sql.SQLException: Access denied for user 'root'@'hostname' (using password: NO)

Which means you will need to make sire that you are entering correct password for "root"  user in the sqoop command . using "--password" option.

Also make sure to add the Grant as following for the root user in MySQL DB so that it can connect to mysql from the host where you are running the sqoop command.

Example:

mysql> GRANT ALL PRIVILEGES ON *.* TO  'root'@'%' IDENTIFIED BY 'XXXXXXXXXX' WITH GRANT OPTION;

 

Please share the output of the following command

# mysql -u root -p
Enter Password: <YOUR_PASSWORD>
mysql> use mysql;
mysql> select user, host FROM user;

 

 

Re: Sqoop jdbc error

Super Mentor

@Manoj690 

Looks like you have marked an incorrect post as "Solution" which simply has an Error posted.  

the post which you have marked as solution simple contains the below error message which makes no sense:

ERROR manager.SqlManager: Error executing statement: java.sql.SQLException: Access denied for user 'root'@'hostname' (using password: NO)

.

Please be careful while marking a post as solution .. 

Re: Sqoop jdbc error

Super Mentor

@Manoj690 

Are you sure that you have downloaded the "mysql-connector-java.jar" of version 5.7 (not version ? because i see that as per: https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-api-changes.html

The name of the class that implements java.sql.Driver in MySQL Connector/J has changed from com.mysql.jdbc.Driver to com.mysql.cj.jdbc.Driver. The old class name has been deprecated.


So in order to test your JDBC driver please try to run the following command to see if it is listing the driver details?

# javap -cp /usr/hdp/sqoop-client/lib/mysql-connector-java.jar com.mysql.jdbc.Driver


Or can you download the MySQL connector version 5.x. from https://dev.mysql.com/downloads/connector/j/5.1.html

 

Re: Sqoop jdbc error

Explorer

 after download the  file  what can we do

Re: Sqoop jdbc error

Super Mentor

@Manoj690 


Looks like you have marked an incorrect answer as "Solution" in this thread.

.