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.

Error can't load postgresql jdbc driver

Error can't load postgresql jdbc driver

Contributor

Hello,

I am new with nifi,
I try to use the jdbc driver sql but I have an error: can not load jdbc driver
Someone can help me
Thank you
5 REPLIES 5
Highlighted

Re: Error can't load postgresql jdbc driver

Super Mentor

@Amira khalifa

Can you please share the exact error that you are getting?

Are you getting the Postgres Driver related errors while configuring the DBCP connection pooling in Nifi?

If Yes, then please check if you have defined the "Database Driver Jar Url" property with the absolute path to you "postgresqlxxxx-jdbc4.jar" JDBC driver jar file. Also please check that this JAR has proper read permission for the Nifi user.

Example:

file:///usr/share/java/postgresql94-jdbc.jar 
file:///c:/postgresql94-jdbc.jar 


Also if you are managing your HDF cluster suing Ambari then you also might want to see the "--jdbc-driver" option to know how to setup postgresql JDBC driver.
https://docs.hortonworks.com/HDPDocuments/HDF3/HDF-3.1.0/bk_installing-hdf-and-hdp/content/setup_opt...

.

Highlighted

Re: Error can't load postgresql jdbc driver

Contributor

This is my configuration i put the absolute path for the driver and I gave Nifi the necessary permissions to use the driver.

I get this message in my log file :

ERROR [StandardProcessScheduler Thread-1] o.a.n.c.s.StandardControllerServiceNode DBCPConnectionPool[id=c25f8f91-0161-1000-a496-8910832bdbd8] F$ org.apache.nifi.reporting.InitializationException: Can't load Database Driver at org.apache.nifi.dbcp.DBCPConnectionPool.getDriverClassLoader(DBCPConnectionPool.java:249) at org.apache.nifi.dbcp.DBCPConnectionPool.onConfigured(DBCPConnectionPool.java:198) at sun.reflect.GeneratedMethodAccessor437.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:137) at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:125) at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:70) at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotation(ReflectionUtils.java:47) at org.apache.nifi.controller.service.StandardControllerServiceNode$2.run(StandardControllerServiceNode.java:409) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.ClassNotFoundException: org.postgresql.Driver

I'm not using Ambari.

Thank you for your response :)

capture.png

Highlighted

Re: Error can't load postgresql jdbc driver

Super Mentor

@Amira khalifa

Please check if the JAR is ok (not corrupted) and it contains the "org.postgresql.Driver" class, you can do so by listing the JAR contents as following:

# su - nifi 
# jar -tvf /home/smadmin/jdbc/postgresql-42.2.1.jar  | grep Driver.class


Also please check the permission of the JAR to findout if the "nifi" user is able to read that JAR? And if the PATH is correct?

# ls -l /home/smadmin/jdbc/postgresql-42.2.1.jar 

.

Highlighted

Re: Error can't load postgresql jdbc driver

Super Mentor

@Amira khalifa

As this issue is resolved and it was because of the classname issue of the driver class, hence can you please mark this HCC thread as Answered by clicking on the "Accept" button that way the mentioned troubleshooting steps can be useful for other HCC users to quickly find/troubleshoot the issue when they see similar issue.

Highlighted

Re: Error can't load postgresql jdbc driver

Contributor

Thank you for your response !

the problem is stupid, I added without intention a return in the line in the driver name! thank you for your help

Don't have an account?
Coming from Hortonworks? Activate your account here