Skip to content
jdbc_fdw

jdbc_fdw

jdbc_fdw : foreign-data wrapper for remote servers available over JDBC

Overview

ID Extension Package Version Category License Language
8530
jdbc_fdw
jdbc_fdw
1.2
FDW
PostgreSQL
C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--s-d-r
No
Yes
No
Yes
yes
no
Relationships
See Also
wrappers
multicorn
odbc_fdw
oracle_fdw
mysql_fdw
tds_fdw
db2_fdw
postgres_fdw

Package/source version 0.5.0; SQL extension version 1.2. PIGSTY RPM and DEB packages cover PostgreSQL 14-18 on x86_64 and aarch64; PGDG RPM 0.4.0 is a legacy alternative for PostgreSQL 14-16. Live queries require a JDBC driver and remote database.

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
MIXED
1.2
18
17
16
15
14
jdbc_fdw -
RPM
PIGSTY
0.5.0
18
17
16
15
14
jdbc_fdw_$v java-11-openjdk-headless
DEB
PIGSTY
0.5.0
18
17
16
15
14
postgresql-$v-jdbc-fdw default-jre-headless, libpq5
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
el8.aarch64
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
el9.x86_64
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
el9.aarch64
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
el10.x86_64
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
el10.aarch64
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
d12.x86_64
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
d12.aarch64
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
d13.x86_64
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
d13.aarch64
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
u22.x86_64
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
u22.aarch64
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
u24.x86_64
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
u24.aarch64
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
u26.x86_64
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
u26.aarch64
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
PIGSTY 0.5.0
Package Version OS ORG SIZE File URL
jdbc_fdw_18 0.5.0 el8.x86_64 pigsty 62.5 KiB jdbc_fdw_18-0.5.0-1PIGSTY.el8.x86_64.rpm
jdbc_fdw_18 0.5.0 el8.aarch64 pigsty 60.4 KiB jdbc_fdw_18-0.5.0-1PIGSTY.el8.aarch64.rpm
jdbc_fdw_18 0.5.0 el9.x86_64 pigsty 61.3 KiB jdbc_fdw_18-0.5.0-1PIGSTY.el9.x86_64.rpm
jdbc_fdw_18 0.5.0 el9.aarch64 pigsty 59.7 KiB jdbc_fdw_18-0.5.0-1PIGSTY.el9.aarch64.rpm
jdbc_fdw_18 0.5.0 el10.x86_64 pigsty 62.0 KiB jdbc_fdw_18-0.5.0-1PIGSTY.el10.x86_64.rpm
jdbc_fdw_18 0.5.0 el10.aarch64 pigsty 60.9 KiB jdbc_fdw_18-0.5.0-1PIGSTY.el10.aarch64.rpm
postgresql-18-jdbc-fdw 0.5.0 d12.x86_64 pigsty 129.5 KiB postgresql-18-jdbc-fdw_0.5.0-1PIGSTY~bookworm_amd64.deb
postgresql-18-jdbc-fdw 0.5.0 d12.aarch64 pigsty 126.7 KiB postgresql-18-jdbc-fdw_0.5.0-1PIGSTY~bookworm_arm64.deb
postgresql-18-jdbc-fdw 0.5.0 d13.x86_64 pigsty 129.5 KiB postgresql-18-jdbc-fdw_0.5.0-1PIGSTY~trixie_amd64.deb
postgresql-18-jdbc-fdw 0.5.0 d13.aarch64 pigsty 126.5 KiB postgresql-18-jdbc-fdw_0.5.0-1PIGSTY~trixie_arm64.deb
postgresql-18-jdbc-fdw 0.5.0 u22.x86_64 pigsty 140.1 KiB postgresql-18-jdbc-fdw_0.5.0-1PIGSTY~jammy_amd64.deb
postgresql-18-jdbc-fdw 0.5.0 u22.aarch64 pigsty 138.4 KiB postgresql-18-jdbc-fdw_0.5.0-1PIGSTY~jammy_arm64.deb
postgresql-18-jdbc-fdw 0.5.0 u24.x86_64 pigsty 134.9 KiB postgresql-18-jdbc-fdw_0.5.0-1PIGSTY~noble_amd64.deb
postgresql-18-jdbc-fdw 0.5.0 u24.aarch64 pigsty 133.9 KiB postgresql-18-jdbc-fdw_0.5.0-1PIGSTY~noble_arm64.deb
postgresql-18-jdbc-fdw 0.5.0 u26.x86_64 pigsty 133.8 KiB postgresql-18-jdbc-fdw_0.5.0-2PIGSTY~resolute_amd64.deb
postgresql-18-jdbc-fdw 0.5.0 u26.aarch64 pigsty 132.1 KiB postgresql-18-jdbc-fdw_0.5.0-2PIGSTY~resolute_arm64.deb

Source

pig build pkg jdbc_fdw;		# build deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install jdbc_fdw;		# install via package name, for the active PG version

pig install jdbc_fdw -v 18;   # install for PG 18
pig install jdbc_fdw -v 17;   # install for PG 17
pig install jdbc_fdw -v 16;   # install for PG 16
pig install jdbc_fdw -v 15;   # install for PG 15
pig install jdbc_fdw -v 14;   # install for PG 14

Create this extension with:

CREATE EXTENSION jdbc_fdw;

Usage

Sources:

jdbc_fdw exposes a JDBC data source as PostgreSQL foreign tables and can execute remote SQL through a helper function. Use it when a suitable JDBC driver exists but no more specialized FDW is available; the JVM, driver JAR, credentials, and remote query behavior all run inside a PostgreSQL backend process.

Core Workflow

CREATE EXTENSION jdbc_fdw;

CREATE SERVER reporting_jdbc
  FOREIGN DATA WRAPPER jdbc_fdw
  OPTIONS (
    drivername 'org.postgresql.Driver',
    url 'jdbc:postgresql://db.example/reporting',
    jarfile '/opt/jdbc/postgresql.jar',
    querytimeout '10',
    maxheapsize '256'
  );

CREATE USER MAPPING FOR app_user
  SERVER reporting_jdbc
  OPTIONS (username 'reader', password 'secret');

CREATE FOREIGN TABLE remote_orders (
  id bigint OPTIONS (key 'true'),
  created_at timestamptz,
  total numeric
) SERVER reporting_jdbc;

SELECT * FROM remote_orders WHERE id = 42;

There are no table-level options in v0.5.0. Foreign columns map by name. Mark the remote primary-key column with OPTIONS (key 'true') when UPDATE or DELETE needs row identity.

Import and Direct SQL

IMPORT FOREIGN SCHEMA public
  FROM SERVER reporting_jdbc
  INTO jdbc_import
  OPTIONS (recreate 'true');

SELECT *
FROM jdbc_exec('reporting_jdbc', 'SELECT id, name FROM customer')
  AS t(id bigint, name text);

The upstream README says IMPORT FOREIGN SCHEMA currently works only with GridDB. jdbc_exec returns record, so queries returning columns require a column definition list.

Important Options and Limits

  • Server options: required drivername and url, absolute jarfile, plus querytimeout and JVM maxheapsize.
  • User-mapping options: username and password.
  • Column option: key = true identifies primary-key columns for writable operations.
  • jdbc_exec(connname, sql) executes driver-specific SQL and can return a defined record set.

Version 0.5.0 supports predicate, column, and aggregate pushdown according to the upstream project, but not remote RETURNING, GROUP BY, ORDER BY, casts, or transaction-control statements. Arrays and foreign-table TRUNCATE are not implemented. Test type conversion and write semantics with the selected driver.

Protect JAR paths and server definitions from untrusted users, keep passwords in user mappings, and bound the JVM heap and remote query time. The source/package release is 0.5.0 while jdbc_fdw.control continues to declare SQL extension version 1.2; use pg_extension.extversion rather than assuming those version spaces are identical.

Last updated on