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.4.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
|
missing el.aarch64
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PGDG
|
0.4.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 |
| 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
|
MISS
|
MISS
|
MISS
|
MISS
|
MISS
|
d12.aarch64
|
MISS
|
MISS
|
MISS
|
MISS
|
MISS
|
d13.x86_64
|
MISS
|
MISS
|
MISS
|
MISS
|
MISS
|
d13.aarch64
|
MISS
|
MISS
|
MISS
|
MISS
|
MISS
|
u22.x86_64
|
MISS
|
MISS
|
MISS
|
MISS
|
MISS
|
u22.aarch64
|
MISS
|
MISS
|
MISS
|
MISS
|
MISS
|
u24.x86_64
|
MISS
|
MISS
|
MISS
|
MISS
|
MISS
|
u24.aarch64
|
MISS
|
MISS
|
MISS
|
MISS
|
MISS
|
| Package | Version | OS | ORG | SIZE | File URL |
|---|---|---|---|---|---|
jdbc_fdw_16 |
0.4.0 |
el8.x86_64 | pgdg | 49.8 KiB | jdbc_fdw_16-0.4.0-1PGDG.rhel8.x86_64.rpm |
jdbc_fdw_16 |
0.4.0 |
el9.x86_64 | pgdg | 49.6 KiB | jdbc_fdw_16-0.4.0-1PGDG.rhel9.x86_64.rpm |
| Package | Version | OS | ORG | SIZE | File URL |
|---|---|---|---|---|---|
jdbc_fdw_15 |
0.4.0 |
el8.x86_64 | pgdg | 50.5 KiB | jdbc_fdw_15-0.4.0-1PGDG.rhel8.x86_64.rpm |
jdbc_fdw_15 |
0.4.0 |
el9.x86_64 | pgdg | 52.0 KiB | jdbc_fdw_15-0.4.0-1PGDG.rhel9.x86_64.rpm |
| Package | Version | OS | ORG | SIZE | File URL |
|---|---|---|---|---|---|
jdbc_fdw_14 |
0.4.0 |
el8.x86_64 | pgdg | 50.5 KiB | jdbc_fdw_14-0.4.0-1PGDG.rhel8.x86_64.rpm |
jdbc_fdw_14 |
0.4.0 |
el9.x86_64 | pgdg | 52.0 KiB | jdbc_fdw_14-0.4.0-1PGDG.rhel9.x86_64.rpm |
Source
Install
Make sure PGDG repo available:
pig repo add pgdg -u # add pgdg 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 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.