jdbc_fdw
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
jdbc_fdw | 0.4.0 | FDW | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 8530 | jdbc_fdw | No | Yes | No | Yes | No | Yes | - |
| Related | wrappers multicorn odbc_fdw oracle_fdw mysql_fdw tds_fdw db2_fdw postgres_fdw |
|---|
missing el.aarch64
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PGDG | 0.4.0 | 1817161514 | jdbc_fdw | - |
| RPM | PGDG | 0.4.0 | 1817161514 | jdbc_fdw_$v | java-11-openjdk-headless |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PGDG MISS | PGDG MISS | PGDG 0.4.0 el8.x86_64.pg16 : jdbc_fdw_16 jdbc_fdw_16-0.4.0-1PGDG.rhel8.x86_64.rpm
| PGDG 0.4.0 el8.x86_64.pg15 : jdbc_fdw_15 jdbc_fdw_15-0.4.0-1PGDG.rhel8.x86_64.rpm
| PGDG 0.4.0 el8.x86_64.pg14 : jdbc_fdw_14 jdbc_fdw_14-0.4.0-1PGDG.rhel8.x86_64.rpm
|
| el8.aarch64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| el9.x86_64 | PGDG MISS | PGDG MISS | PGDG 0.4.0 el9.x86_64.pg16 : jdbc_fdw_16 jdbc_fdw_16-0.4.0-1PGDG.rhel9.x86_64.rpm
| PGDG 0.4.0 el9.x86_64.pg15 : jdbc_fdw_15 jdbc_fdw_15-0.4.0-1PGDG.rhel9.x86_64.rpm
| PGDG 0.4.0 el9.x86_64.pg14 : jdbc_fdw_14 jdbc_fdw_14-0.4.0-1PGDG.rhel9.x86_64.rpm
|
| el9.aarch64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| el10.x86_64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| el10.aarch64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| d12.x86_64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| d12.aarch64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| d13.x86_64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| d13.aarch64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| u22.x86_64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| u22.aarch64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| u24.x86_64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| u24.aarch64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
Install
You can install jdbc_fdw directly. First, make sure the PGDG repository is added and enabled:
pig repo add pgdg -u # Add PGDG repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install jdbc_fdw; # Install for current active PG version
pig ext install -y jdbc_fdw -v 16 # PG 16
pig ext install -y jdbc_fdw -v 15 # PG 15
pig ext install -y jdbc_fdw -v 14 # PG 14
dnf install -y jdbc_fdw_16 # PG 16
dnf install -y jdbc_fdw_15 # PG 15
dnf install -y jdbc_fdw_14 # PG 14
Create Extension:
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.
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.