PostgreSQL Driver Adapter

Current postgresql versions are valid bundles and also provide a DataSourceFactory. So if you use a recent version you will not need this adapter anymore.


The Pax JDBC PostgreSQL Driver Adapter registers a DataSourceFactory in the OSGi service registry, adapting implementation classes from an osgified PostgreSQL JDBC Driver.

The official Maven artifact postgresql:postgresql is a plain old JAR without OSGi manifest headers. You will have to wrap this on the fly using the Pax URL wrap: handler, or build your own bundle, adding an OSGi manifest. This gap is to be filled by the Pax Tipi project.

The DataSourceFactory methods of this adapter produces objects with the following implementation classes:

  • org.postgresql.Driver
  • PGSimpleDataSource
  • PGConnectionPoolDataSource
  • PGXADataSource

Service Properties

The PostgreSQL Driver Adapter registers its DataSourceFactory with the following service properties:

  • osgi.jdbc.driver.class = org.postgresql.Driver
  • = postgresql

Method Arguments

The argument passed to createDataSource(), createConnectionPoolDataSource(), createXADataSource() supports the following properties:

  • DataSourceFactory.JDBC_DATABASE_NAME (mandatory)
  • DataSourceFactory.JDBC_USER
  • DataSourceFactory.JDBC_PASSWORD

An SQLException is thrown if any other properties are set or if a mandatory property is missing.


This method returns an instance of org.postgresql.Driver. Any properties passed to this method are ignored.

Obtaining a DataSourceFactory

To obtain a DataSourceFactory, use any OSGi service lookup or injection method (Declarative Services, Blueprint) of your choice and specify the following properties:

  • objectClass = org.osgi.service.jdbc.DataSourceFactory

and at least one of

  • osgi.jdbc.driver.class = org.postgresql.Driver
  • = postgresql

Required Maven Artifacts

  • org.ops4j.pax.jdbc:pax-jdbc-postgresql
  • An OSGi-ready wrapped version of postgresql:postgresql
  • org.osgi:org.osgi.enterprise:4.2.0
  • An OSGi 4.2 framework