Postgresql Jdbc Driver Known Issues and Quick Fixes



can't load driver class 'org.postgresql.Driver' Windows ERROR

Can't create Postgresql Jdbc Driver instance ? Getting error while creating driver 'PostgreSQL' instance ? can't load driver class 'org.postgresql.Driver' ? If your are installing postgresql for the first time, Here are the step by step procedure on how to install postgresql jdbc driver on windows.


  1. Download Latest Version of Postgresql Jdbc Driver
  2. Install / Configure Postgresql Jdbc Driver
  3. Troubleshoot Postgresql Jdbc Driver ERROR

  4. #1 Downloand : Postgresql Jdbc Driver



    To downloand Postgresql Jdbc Driver version you would like to install on any SQL Developer Clients or Data Modeller tools like DBeaver. Go to https://jdbc.postgresql.org/download.html and download the latest stable version.

    download postgresql jdbc driver



    #2 Configure : Postgresql Jdbc Driver



    There are different ways to configure postgresql jdbc driver. If you are using any postgres db client / data model tools, you need to add postgresql jdbc driver jar to the SQL client's driver manager. Here is an example of adding postgresql jdbc driver to the DBeaver modelling tool's driver manager. Similarly you can add postgresql jdbc driver to any thirdpary postgresql clients.

    Command Prompt ERROR : could not find java dll



    #3 PostgreSQL Known Issues and Fixes


    3.1 Error org.postgresql.driver not loaded or 3.2 Failed to load driver class org.postgresql.Driver


    If driver is not compatible with the client's supported jdbc version you might get error as shown below.
    		
    Can't create driver instance
    Error creating driver 'PostgreSQL' instance.
    Most likely required jar files are missing.
    You should configure jars in driver settings.
    
    Reason: can't load driver class 'org.postgresql.Driver'
    Error creating driver 'PostgreSQL' instance.
    Most likely required jar files are missing.
    You should configure jars in driver settings.
    
    Reason: can't load driver class 'org.postgresql.Driver'
    org.postgresql.Driver
    org.postgresql.Driver
    		
    		


    Postgresql Jdbc Driver Maven Dependancy.



    If you are connecting to postgresql programmatically, you need to add postgresql jdbc driver maven dependancy to your projects pom.xml. to get more details about the postgresql jdbc driver maven dependancy, go to https://search.maven.org/artifact/org.postgresql/ and add appropriate postgresql jdbc driver maven artifact version to pom.xml file.

    		
    		
    <dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>42.2.18.jre7</version>
    </dependency>
    			
    			


    Note:

    You might get Failed to load driver class org.postgresql.Driver error if above artifact is missing from pom.xml file.

    
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource
    	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:656) ~[spring-beans-5.3.1.jar:5.3.1]
    	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:636) ~[spring-beans-5.3.1.jar:5.3.1]
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336) ~[spring-beans-5.3.1.jar:5.3.1]
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1179) ~[spring-beans-5.3.1.jar:5.3.1]
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:571) ~[spring-beans-5.3.1.jar:5.3.1]
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531) ~[spring-beans-5.3.1.jar:5.3.1]
    	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.1.jar:5.3.1]
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.1.jar:5.3.1]
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.1.jar:5.3.1]
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.1.jar:5.3.1]
    	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.1.jar:5.3.1]
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1367) ~[spring-beans-5.3.1.jar:5.3.1]
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1287) ~[spring-beans-5.3.1.jar:5.3.1]
    	at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:885) ~[spring-beans-5.3.1.jar:5.3.1]
    	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:789) ~[spring-beans-5.3.1.jar:5.3.1]
    	... 95 common frames omitted
    Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource
    	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.1.jar:5.3.1]
    	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:651) ~[spring-beans-5.3.1.jar:5.3.1]
    	... 109 common frames omitted
    Caused by: org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource
    	at org.springframework.boot.context.properties.bind.Binder.handleBindError(Binder.java:363) ~[spring-boot-2.4.0.jar:2.4.0]
    	at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:323) ~[spring-boot-2.4.0.jar:2.4.0]
    	at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:308) ~[spring-boot-2.4.0.jar:2.4.0]
    	at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:238) ~[spring-boot-2.4.0.jar:2.4.0]
    	at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:212) ~[spring-boot-2.4.0.jar:2.4.0]
    	at org.springframework.boot.jdbc.DataSourceBuilder.bind(DataSourceBuilder.java:95) ~[spring-boot-2.4.0.jar:2.4.0]
    	at org.springframework.boot.jdbc.DataSourceBuilder.build(DataSourceBuilder.java:78) ~[spring-boot-2.4.0.jar:2.4.0]
    	at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration.createDataSource(DataSourceConfiguration.java:48) ~[spring-boot-autoconfigure-2.4.0.jar:2.4.0]
    	at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari.dataSource(DataSourceConfiguration.java:90) ~[spring-boot-autoconfigure-2.4.0.jar:2.4.0]
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
    	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
    	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.1.jar:5.3.1]
    	... 110 common frames omitted
    Caused by: java.lang.IllegalStateException: Unable to set value for property driver-class-name
    	at org.springframework.boot.context.properties.bind.JavaBeanBinder$BeanProperty.setValue(JavaBeanBinder.java:357) ~[spring-boot-2.4.0.jar:2.4.0]
    	at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:98) ~[spring-boot-2.4.0.jar:2.4.0]
    	at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:80) ~[spring-boot-2.4.0.jar:2.4.0]
    	at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:56) ~[spring-boot-2.4.0.jar:2.4.0]
    	at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$5(Binder.java:451) ~[spring-boot-2.4.0.jar:2.4.0]
    	at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:571) ~[spring-boot-2.4.0.jar:2.4.0]
    	at org.springframework.boot.context.properties.bind.Binder$Context.withDataObject(Binder.java:557) ~[spring-boot-2.4.0.jar:2.4.0]
    	at org.springframework.boot.context.properties.bind.Binder$Context.access$300(Binder.java:512) ~[spring-boot-2.4.0.jar:2.4.0]
    	at org.springframework.boot.context.properties.bind.Binder.bindDataObject(Binder.java:449) ~[spring-boot-2.4.0.jar:2.4.0]
    	at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:390) ~[spring-boot-2.4.0.jar:2.4.0]
    	at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:319) ~[spring-boot-2.4.0.jar:2.4.0]
    	... 122 common frames omitted
    Caused by: java.lang.reflect.InvocationTargetException: null
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
    	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
    	at org.springframework.boot.context.properties.bind.JavaBeanBinder$BeanProperty.setValue(JavaBeanBinder.java:354) ~[spring-boot-2.4.0.jar:2.4.0]
    	... 132 common frames omitted
    Caused by: java.lang.RuntimeException: Failed to load driver class org.postgresql.Driver in either of HikariConfig class loader or Thread context classloader
    	at com.zaxxer.hikari.HikariConfig.setDriverClassName(HikariConfig.java:486) ~[HikariCP-3.4.5.jar:na]
    	... 137 common frames omitted
    
    


    Postgresql Jdbc related issues / solution on StackOverflow


    Known issues postgresql jdbc


    Here is the list of all Postgresql JDBC related known issues and solutions.

    #1 getting error: Could not load JDBC driver class [org.postgresql.Driver]
    #2 hivethriftserver built into spark3.0.0. is throwing error "org.postgresql.Driver" was not found in the CLASSPATH
    #3 execution failed for the task class not found `org.postgresql.Driver`
    #4 Why is "Driver not found: [org.postgresql.Driver]" with postgresql 9.3-1102.jdbc41 dependency declared?
    #5 JDBC driver not available for 'org.postgresql.Driver' on Spring Roo
    #6 error: java.lang.ClassNotFoundException: org.postgresql.Driver
    #7 Install postgresql with play! framework (Driver not found: [org.postgresql.Driver])
    #8 org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'org.postgresql.Driver'
    #9 java.lang.ClassNotFoundException: org.postgresql.Driver with Maven
    #10 SoapUI: 5.6.0 java.lang.ClassNotFoundException: PostgreSQL/org.postgresql.Driver when running tests using maven
    #11 Cannot find database driver: org.postgresql.Driver
    #12 Class.forName("org.postgresql.Driver") while inetgrating with Postgresql
    #13 Invalid property 'driverClass' of bean class [org.springframework.jdbc.datasource.DriverManagerDataSource] for org.postgresql.Driver
    #14 Property 'driverClassName' threw exception; Could not load JDBC driver class [org.postgresql.Driver]
    #15 java.lang.ClassNotFoundException: org.postgresql.Driver from jooq code generating task
    #16 Unsupported major.minor version 51.0 (unable to load class org.postgresql.Driver)
    #17 Tomcat7 ClassNotFoundException on org.postgresql.Driver
    #18 Error "org.postgresql.Driver is not a valid javax.sql.DataSource implementation" that doesn`t affect anything. How to remove it?
    #19 Spring Data java configuration doesn't find the org.postgresql.Driver
    #20 org.postgresql.Driver not working in NetBeans
    #21 How can I connect to Postgres using JayDeBeApi? It doesn't find the org.postgresql.Driver
    #22 Error While connecting to postgresql with pyspark in shell - org.postgresql.Driver Class not found exception
    #23 df.show returning java.lang.ClassNotFoundException: org.postgresql.Driver
    #24 Jython on Linux: driver [org.postgresql.Driver] not found
    #25 Why does Play fail with "Driver not found: [org.postgresql.Driver]"?
    #26 ClassNotFoundException (org.postgresql.Driver) with connection pooling example
    #27 Class.forName("org.postgresql.Driver") error
    #28 Driver:org.postgresql.Driver@3ed03652 returned null for URL... While deployin spring boot to Heroku
    #29 Hibernate IntelliJ - Unable to load class [org.postgresql.Driver]
    #30 pyspark dataframe error due to java.lang.ClassNotFoundException: org.postgresql.Driver


    PostgreSQL Other Known Issues

    Thread Author Time
    Re: BUG #16951: pg_restore segfaults on custom format piped from a different version of PG Sergey KOPOSOV 13:05
    Re: BUG #16951: pg_restore segfaults on custom format piped from a different version of PG Tom Lane 15:39
    Re: BUG #16951: pg_restore segfaults on custom format piped from a different version of PG Justin Pryzby 17:56
    Re: BUG #16951: pg_restore segfaults on custom format piped from a different version of PG Tom Lane 18:13
    Re: Since '2001-09-09 01:46:40'::timestamp microseconds are lost when extracting epoch 📎 Peter Eisentraut 18:49

    April 2, 2021

    Thread Author Time
    RE: BUG #16922: In cascading replication, a standby server aborted when an upstream standby server promoted egashira 11:09
    standby fails with out-of-order XID insertion upon start 📎 Radoslav Nedyalkov 13:51
    Re: Inconsistent behavior of pg_dump/pg_restore on DEFAULT PRIVILEGES Boris P. Korzun 14:09
    Re: Number of Shared Blocks Hit Andres Freund 17:35