Skip to content
Browse files

fix: make sure org.postgresql.Driver is loaded when accessing though …

…DataSource interface

This initialization was removed by accident in c99507b

closes #768
  • Loading branch information
vlsi committed Mar 8, 2017
1 parent bd0497d commit 9c80adc24776ae02e0aff419e1cddf26a28eeff0
Showing with 15 additions and 0 deletions.
  1. +15 −0 pgjdbc/src/main/java/org/postgresql/ds/common/
@@ -52,6 +52,21 @@
// Map for all other properties
private Properties properties = new Properties();

* Ensure the driver is loaded as JDBC Driver might be invisible to Java's ServiceLoader.
* Usually, {@code Class.forName(...)} is not required as {@link DriverManager} detects JDBC drivers
* via {@code META-INF/services/java.sql.Driver} entries. However there might be cases when the driver
* is located at the application level classloader, thus it might be required to perform manual
* registration of the driver.
static {
try {
} catch (ClassNotFoundException e) {
throw new IllegalStateException("BaseDataSource is unable to load org.postgresql.Driver. Please check if you have proper PostgreSQL JDBC Driver jar on the classpath", e);

* Gets a connection to the PostgreSQL database. The database is identified by the DataSource
* properties serverName, databaseName, and portNumber. The user to connect as is identified by

0 comments on commit 9c80adc

Please sign in to comment.