Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

"Can't load database driver" in CaptureChangesMysql Apache Nifi Processors

Highlighted

"Can't load database driver" in CaptureChangesMysql Apache Nifi Processors

New Contributor

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.4110381-screenshot-2019-08-13-at-55200-pm.png110352-screenshot-2019-08-13-at-55802-pm.png

9 REPLIES 9

Re: "Can't load database driver" in CaptureChangesMysql Apache Nifi Processors

Guru

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...


110362-20484-3-capturechangemysql-properties.png

Re: "Can't load database driver" in CaptureChangesMysql Apache Nifi Processors

Community Manager

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.

Re: "Can't load database driver" in CaptureChangesMysql Apache Nifi Processors

New Contributor

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...)

110355-screenshot-2019-08-14-at-122627-pm.png

Re: "Can't load database driver" in CaptureChangesMysql Apache Nifi Processors

Guru

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.

Re: "Can't load database driver" in CaptureChangesMysql Apache Nifi Processors

New Contributor

Hello @alim 

Yes, the driver path is correct and attached the screenshot from the finder .

 

Screenshot 2019-08-21 at 5.19.08 PM.png

Re: "Can't load database driver" in CaptureChangesMysql Apache Nifi Processors

Super Mentor

@kiranps11 

 

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 {};
}

 

Re: "Can't load database driver" in CaptureChangesMysql Apache Nifi Processors

New Contributor

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 .

 

Screenshot 2019-08-22 at 1.33.46 PM.pngScreenshot 2019-08-22 at 1.34.02 PM.png

Re: "Can't load database driver" in CaptureChangesMysql Apache Nifi Processors

Super Mentor

@kiranps11 

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"

 

Re: "Can't load database driver" in CaptureChangesMysql Apache Nifi Processors

New Contributor

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 .Screenshot 2019-08-22 at 3.20.14 PM.pngScreenshot 2019-08-22 at 3.20.22 PM.pngScreenshot 2019-08-22 at 3.20.46 PM.png