Skip to content
atris edited this page Aug 11, 2012 · 20 revisions

Introduction

JDBC_FDW is a Foreign Data Wrapper(FDW) for PostgreSQL (9.1 onwards).It can be used to fetch data from any data source that support JDBC into PostgreSQL tables.The FDW also supports basic query cancellation(Control C) and dynamic loading of JDBC drivers.

The project is a Google Summer Of Code 2012 project.Original project proposal can be found here.

Design Details

JDBC_FDW uses Java Native Interface(JNI).JNI is an interface for calling Java code from native code and vice versa.

Most of the database systems these days support JDBC.Hence,JDBC_FDW can be the universal FDW for PostgreSQL to fetch data from them.

Installation Instructions for various platforms

The Installation Instructions for various platforms are:

Installation instructions

Examples

The following is an example of usage of JDBC_FDW:

JDBC_FDW is being used to fetch data to PostgreSQL 9.2beta2 from a SQLite database.

Table : stest1

sqlite> SELECT * FROM stest1;  
4|5|6 
7|8|9
1|2|3
100|200|300
600|700|800
1100|1200|1300
1450|1650|1950
1900|1950|
||
||1024
sqlite> 

In PostgreSQL,a foreign table test13 is created who's data comes from the query 'SELECT * FROM stest1'

Table : test13

gitc=# SELECT * FROM test13;
Connection to SQLite 3.7.2 successful.

  a   |  b   |  c   
------+------+------
    4 |    5 |    6
    7 |    8 |    9
    1 |    2 |    3
  100 |  200 |  300
  600 |  700 |  800
 1100 | 1200 | 1300
 1450 | 1650 | 1950
 1900 | 1950 |     
      |      |     
      |      | 1024
(10 rows)

Time: 413.964 ms
gitc=# 

Options

The options for configuring JDBC_FDW are:

drivername : The name of the JDBC driver which shall be used for connecting and fetching data from the foreign database.(Compulsory)

url : The JDBC URL that shall be used to connect and fetch data from the foreign database.(Compulsory)

query : An SQL query to define the data set on the JDBC server.

table : The name of a table (quoted and qualified as required) on the foreign database table.

(Either table or query have to be specified necessarily)

username: The username to use when connecting to foreign database.
          Default <none>

password: The password to authenticate to the foreign database with.
          Default: <none>

querytimeout: The time after which a currently running query,if not completed yet,shall be terminated.
              Default: <none>
   
jarfile: The path and name(e.g. /folder1/folder2/abc.jar) of the JAR file which contains the JDBC driver of the foreign database from which data shall be fetched.(Compulsory)

maxheapsize: The value of the maximum heap size of the JVM being used in jdbc fdw.Please read the notes about maxheapsize in installation instructions carefully before setting a value for this option.
Clone this wiki locally