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 | 0.5.0 | 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. PGDG RPM is PG14-16 and missing EL aarch64; PIGSTY DEB is PG14-18 on amd64 and arm64, with a downstream PG18 compatibility patch. Live queries require a JDBC driver and remote database.
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | MIXED | 0.5.0 | 18 17 16 15 14 | jdbc_fdw | - |
| RPM | PGDG | 0.4.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 | MISS | MISS | PGDG 0.4.0 | PGDG 0.4.0 | PGDG 0.4.0 |
el8.aarch64 | MISS | MISS | MISS | MISS | MISS |
el9.x86_64 | MISS | MISS | PGDG 0.4.0 | PGDG 0.4.0 | PGDG 0.4.0 |
el9.aarch64 | MISS | MISS | MISS | MISS | MISS |
el10.x86_64 | MISS | MISS | MISS | MISS | MISS |
el10.aarch64 | MISS | MISS | MISS | MISS | MISS |
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 |
Source
pig build pkg jdbc_fdw; # build debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall 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 14Create this extension with:
CREATE EXTENSION jdbc_fdw;Usage
jdbc_fdw: Foreign data wrapper for remote servers available over JDBC
Create Server
CREATE EXTENSION jdbc_fdw;
CREATE SERVER jdbc_server FOREIGN DATA WRAPPER jdbc_fdw
OPTIONS (
drivername 'org.postgresql.Driver',
url 'jdbc:postgresql://remotehost:5432/mydb',
jarfile '/usr/share/java/postgresql.jar',
maxheapsize '256'
);Server Options: drivername (required, JDBC driver class), url (required, JDBC connection URL), jarfile (required, absolute path to JDBC driver JAR), querytimeout (query timeout in seconds), maxheapsize (JVM heap size in MB, minimum 1).
Create User Mapping
CREATE USER MAPPING FOR CURRENT_USER SERVER jdbc_server
OPTIONS (username 'dbuser', password 'dbpass');Create Foreign Table
CREATE FOREIGN TABLE remote_table (
id integer OPTIONS (key 'true'),
name text,
value numeric
)
SERVER jdbc_server
OPTIONS (table_name 'schema.tablename');Set key 'true' on primary key columns to enable UPDATE and DELETE operations.
Query Remote Data
SELECT * FROM remote_table WHERE id > 100;Execute Arbitrary SQL with jdbc_exec
The jdbc_exec function executes SQL against the remote database and returns result sets:
SELECT * FROM jdbc_exec('jdbc_server', 'SELECT id, name FROM remote_schema.remote_table WHERE status = 1')
AS t(id integer, name text);This is useful for executing queries that go beyond the foreign table definition, including DDL or complex queries on the remote server.