Created on 08-13-2019 12:32 PM - edited 08-17-2019 04:10 PM
I am using the CaptureChangesMysql processor to read the events data from mysql but it failing with the connection error as "org.apache.nifi.reporting.initializationexception can't load database driver"
screenshots are attached for the reference .
Mysql Driver path: file:////Users/kiran/Downloads/mysql/mysql-connector-java-8.0.17.jar
Environment :
Aapache nifi :1.7.0
Mysql 8.0.17
OS : MacOS 10.14.4
Created on 08-13-2019 01:19 PM - edited 08-17-2019 04:10 PM
I believe your path to your driver is incorrect. It should be:
/Users/kiran/Downloads/mysql/...
Here is an example processor setup from my CDC article (https://community.hortonworks.com/content/kbentry/113941/change-data-capture-cdc-with-apache-nifi-ve...😞
Created 08-13-2019 03:34 PM
The above question and the entire response thread below was originally posted in the Community Help track. On Tue Aug 13 15:34 UTC 2019, a member of the HCC moderation staff moved it to the Data Ingestion & Streaming track. The Community Help Track is intended for questions about using the HCC site itself.
Created on 08-14-2019 06:59 AM - edited 08-17-2019 04:09 PM
Hello @Andrew Lim
Thanks for the Response .
The Driver path is "/Users/kiran/Downloads/mysql/mysql-connector-java-8.0.17.jar" i have tried this as well but getting the error as this path is not a valid File or Url . attached the screenshot for your reference .
I went through this documents as well (https://community.hortonworks.com/content/kbentry/113941/change-data-capture-cdc-with-apache-nifi-ve...)
Created 08-14-2019 02:51 PM
Are you sure the driver path is correct? Can you provide a screenshot of your Finder window where the jar file is located?
The only way I can reproduce the "Not a valid URL or file" warning is if the path is wrong. When I point to this path on my machine (Mac OS 10.14.2), I have no errors:
/Users/andrewmlim/Downloads/mysql-connector-java-8.0.17/mysql-connector-java-8.0.17.jar
Also, the HCC UI is not helpful since the link is very small, but it is better to select "Add comment" as a response to an answer instead of creating a new Answer.
Created 08-21-2019 04:53 AM
Created 08-21-2019 05:27 AM
Can you please share the output of the following command? This is because the path may be correct and file might be existing.
Additional Possibilities:
1. The other possibility is that the File may not be readable by the Nifi Process.
# ls -lart /Users/kiran/Downloads/mysql/mysql-connector-java-8.0.17.jar
So can you please double check if the use who is running the NiFi process has access to this JAR and the permission on this JAR are correct?
2. The JAR may be a corrupted jar so NiFi process might not be able to read the driver class from this jar. So please list the classes present inside this JAR using the following command.. or try to grep the class.
Example: Try to check the existence of this class in the JAR, By the same user who is running the NiFi process.
# /usr/jdk64/jdk1.8.0_112/bin/javap -cp/Users/kiran/Downloads/mysql/mysql-connector-java-8.0.17.jar com.mysql.jdbc.Driver
Compiled from "Driver.java"
public class com.mysql.jdbc.Driver extends com.mysql.jdbc.NonRegisteringDriver implements java.sql.Driver {
public com.mysql.jdbc.Driver() throws java.sql.SQLException;
public java.util.logging.Logger getParentLogger() throws java.sql.SQLFeatureNotSupportedException;
static {};
}
Created 08-22-2019 01:05 AM
Hello @jsensharma
Thanks for the Response .
I have tried both the steps which you have mentioned and looks both are working as expected .
screenshots are attached for the reference .
Created 08-22-2019 02:07 AM
Looks like you are using Mysql-connector-java.jar of version 8.
Which has some changes in the driver class name 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 can you please try any of the following approach and see if it works?
Option-1). Either use 5.7 mysql-connector-java.jar with JDBC driver class name as "com.mysql.jdbc.Driver"
(OR)
Option-2). With mysql-connector-java.jar (of version 😎 please try using the new driver class name "com.mysql.cj.jdbc.Driver"
Created on 08-22-2019 03:01 AM - edited 08-22-2019 03:08 AM
Hello @jsensharma
Thanks for the Response
I have tried with the Option2(added the driver name as"com.mysql.cj.jdbc.Driver")
there are two scenarios :
1. Mysql driver location with "file://"
Mysql Driver Location :"file:///Users/kiran/Downloads/mysql/mysql-connector-java-8.0.17.jar"
Mysql Class Name: com.mysql.cj.jdbc.Driver
i am getting the error "Failed to register JDBC driver. Ensure MySQL Driver Location(s) and MySQL Driver Class Name are configured correctly. org.apache.nifi.reporting.InitializationException: Can't load Database Driver"
2. Getting the error as "capture-changes-mysql-driver-location is validated against '/Users/kiran/Downloads/mysql/mysql-connector-java-8.0.17.jar' is invalid because not a valid url or file" When I mentioned the Mysql Driver Location as "/Users/kiran/Downloads/mysql/mysql-connector-java-8.0.17.jar""
I have attached the screenshot for the same .