{"id":37782581,"url":"https://github.com/pgspider/jdbc_fdw","last_synced_at":"2026-01-16T15:09:23.360Z","repository":{"id":37394650,"uuid":"439217591","full_name":"pgspider/jdbc_fdw","owner":"pgspider","description":"JDBC Foreign Data Wrapper for PostgreSQL","archived":false,"fork":false,"pushed_at":"2024-12-24T07:21:02.000Z","size":1045,"stargazers_count":71,"open_issues_count":27,"forks_count":24,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-12-24T08:27:59.371Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PLpgSQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pgspider.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-12-17T05:11:49.000Z","updated_at":"2024-12-24T07:21:09.000Z","dependencies_parsed_at":"2023-12-26T01:24:08.806Z","dependency_job_id":"b3427db9-2ba4-4df7-a52d-47dc2f61330c","html_url":"https://github.com/pgspider/jdbc_fdw","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/pgspider/jdbc_fdw","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgspider%2Fjdbc_fdw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgspider%2Fjdbc_fdw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgspider%2Fjdbc_fdw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgspider%2Fjdbc_fdw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pgspider","download_url":"https://codeload.github.com/pgspider/jdbc_fdw/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgspider%2Fjdbc_fdw/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28479406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-16T15:09:23.270Z","updated_at":"2026-01-16T15:09:23.338Z","avatar_url":"https://github.com/pgspider.png","language":"PLpgSQL","funding_links":[],"categories":[],"sub_categories":[],"readme":"JDBC Foreign Data Wrapper for PostgreSQL\n============================================\n\nThis is a foreign data wrapper (FDW) to connect [PostgreSQL](https://www.postgresql.org/)\nto any Java DataBase Connectivity (JDBC) data source.\n\nThis `jdbc_fdw` is based on [JDBC\\_FDW](http://github.com/atris/JDBC_FDW.git) and [jdbc2\\_fdw](https://github.com/heimir-sverrisson/jdbc2_fdw).\n\n\u003cimg src=\"https://upload.wikimedia.org/wikipedia/commons/2/29/Postgresql_elephant.svg\" align=\"center\" height=\"100\" alt=\"PostgreSQL\"/\u003e\t+\t\u003cimg src=\"https://1000logos.net/wp-content/uploads/2020/09/Java-Logo-500x313.png\" align=\"center\" height=\"100\" alt=\"JDBC\"/\u003e\n\n\nContents\n--------\n\n1. [Features](#features)\n2. [Supported platforms](#supported-platforms)\n3. [Installation](#installation)\n4. [Usage](#usage)\n5. [Functions](#functions)\n6. [Identifier case handling](#identifier-case-handling)\n7. [Generated columns](#generated-columns)\n8. [Character set handling](#character-set-handling)\n9. [Examples](#examples)\n10. [Limitations](#limitations)\n11. [Contributing](#contributing)\n12. [Useful links](#useful-links)\n13. [License](#license)\n\nFeatures\n--------\n### Common features\n\n#### Write-able FDW\nThe existing JDBC FDWs are only read-only, this version provides the write capability.\nThe user can now issue an insert, update, and delete statement for the foreign tables using the jdbc_fdw.\n\n#### Arbitrary SQL query execution via function\nSupport execute the whole sql query and get results from the DB behind jdbc connection. This function returns a set of records.\n\nSyntax:\n```\njdbc_exec(text connname, text sql);\n```\n\nExample:  \nTo get a set of record, use the below sql query:\n```\nSELECT jdbc_exec(jdbc_svr, 'SELECT * FROM tbl');\n              jdbc_exec                 \n----------------------------------------\n (1,abc,\"Fri Dec 31 16:00:00 1999 PST\")\n (2,def,\"Fri Dec 31 16:00:00 1999 PST\")\n ```\nTo get a set of record with separate data for each column, use the below sql query:\n```\nSELECT * FROM jdbc_exec(jdbc_svr, 'SELECT * FROM tbl') as t(id int, c1 text, c2 timestamptz);\n id |  c1 |              c2              \n----+-----+------------------------------\n  1 | abc | Fri Dec 31 16:00:00 1999 PST\n  2 | def | Fri Dec 31 16:00:00 1999 PST\n```\n\n### Pushdowning\n\n#### WHERE clause push-down\nThe jdbc_fdw will push-down the foreign table where clause to the foreign server.\nThe where condition on the foreign table will be executed on the foreign server, hence there will be fewer rows to bring across to PostgreSQL.\nThis is a performance feature.\n\n#### Column push-down\nThe existing JDBC FDWs are fetching all the columns from the target foreign table.\nThe latest version does the column push-down and only brings back the columns that are part of the select target list.\nThis is a performance feature.\n\n#### Aggregate function push-down\nList of aggregate functions push-down:\n```\nsum, avg, stddev, stddev_pop, stddev_samp, var_pop, var_samp, variance, max, min, count.\n```\n### Notes about features\n\n#### Maximum digits storing float value of MySQL\nMaximum digits storing float value of MySQL is 6 digits. The stored value may not be the same as the value inserted.\n\n#### Variance function\nVariance function: For MySQL, variance function is alias for var_pop(). For PostgreSQL/GridDB, variance function is alias for var_samp(). Due to the different meaning of variance function between MySQL and PostgreSQL/GridDB, the result will be different.\n\n#### Concatenation Operator\nThe || operator as a concatenation operator is standard SQL, however in MySQL, it represents the OR operator (logical operator). If the PIPES_AS_CONCAT SQL mode is enabled, || signifies the SQL-standard string concatenation operator (like CONCAT()). User needs to enable PIPES_AS_CONCAT mode in MySQL for concatenation.\n\n#### Timestamp range\nThe MySQL timestamp range is not the same as the PostgreSQL timestamp range, so be careful if using this type. In MySQL, TIMESTAMP has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC.\n\n#### JDBC connection\n`jdbc_fdw` runs on the Postgres server and uses its IP address to make connections, which can make many trusted requests to the server's network. For example, when trusted local authentication is enabled in the PostgreSQL server, jdbc_fdw can connect to the loopback server (127.0.0.1) with any username (including the root account) without require password.\nSo be careful when granting permissions of `FOREIGN SERVER` and `USER MAPPING` to non-supperuser.\n\nReference\n#### Write-able FDW\nThe user can issue an update and delete statement for the foreign table, which has set the primary key option.\n\n\nSupported platforms\n-------------------\n\n`jdbc_fdw` was developed on Linux, and should run on any\nreasonably POSIX-compliant system.\n\n`jdbc_fdw` is designed to be compatible with PostgreSQL 13 ~ 17.\nJava 5 or later is required (Confirmed version is Java OpenJDK 1.8.0).\n\nInstallation\n------------\n\n### Source installation\n\nPrerequisites:\n\n- JDBC driver(.jar file) of the database is needed.\nFor example, jar file can be found from below:\n[PostgreSQL](https://jdbc.postgresql.org/)\n[GridDB](https://github.com/griddb/jdbc)\n\n#### 1. To build jdbc_fdw, you need to symbolic link the jvm library to your path.\n\n```\nsudo ln -s /usr/lib/jvm/[java version]/jre/lib/amd64/server/libjvm.so /usr/lib64/libjvm.so\n```\n\n#### 2. Build and install jdbc_fdw\n\nAdd a directory of `pg_config` to PATH and build and install `jdbc_fdw`.\n\n```sh\nmake USE_PGXS=1\nmake install USE_PGXS=1\n```\n\nIf you want to build `jdbc_fdw` in a source tree of PostgreSQL, use\n```sh\nmake\nmake install\n```\nYou may have to change to root/installation privileges before executing 'make install'\n\nUsage\n-----\n\n## CREATE SERVER options\n\n`jdbc_fdw` accepts the following options via the `CREATE SERVER` command:\n\n- **drivername** as *string*\n\t\t\n  The name of the JDBC driver.\n  Note that the driver name has to be specified for jdbc_fdw to work.\n  It can be found in JDBC driver documentation.\n  * [PostgreSQL](https://jdbc.postgresql.org/documentation/head/load.html) `drivername 'org.postgresql.Driver'`\n  * [GridDB](http://www.toshiba-sol.co.jp/en/pro/griddb/docs-en/v4_1/GridDB_AE_JDBC_DriverGuide.html) `drivername 'com.toshiba.mwcloud.gs.sql.Driver'`\n\n- **url** as *string*\n\n  The JDBC URL that shall be used to connect to the foreign database.\n  Note that URL has to be specified for jdbc_fdw to work.\n  It can be found in JDBC driver documentation.\n  * [PostgreSQL](https://jdbc.postgresql.org/documentation/head/load.html) `url 'jdbc:postgresql://[host]:[port]/[database]'`\n  * [GridDB](http://www.toshiba-sol.co.jp/en/pro/griddb/docs-en/v4_1/GridDB_AE_JDBC_DriverGuide.html) `url 'jdbc:gs://[host]:[port]/[clusterName]/[databaseName]'`\n\n- **querytimeout** as *integer*\n\n  The number of seconds that an SQL statement may execute before timing out.\n  The option can be used for terminating hung queries.\n\n- **jarfile** as *string*\n\n  The path and name(e.g. folder1/folder2/abc.jar) of the JAR file of the JDBC driver to be used of the foreign database.\nNote that the path must be absolute path.\n```\n/[path]/[jarfilename].jar\n```\n\n- **maxheapsize** as *integer*\n  \n  The value of the option shall be set to the maximum heap size of the JVM which is being used in jdbc fdw. It can be set from 1 Mb onwards. This option is used for setting the maximum heap size of the JVM manually.\n\n\n## CREATE USER MAPPING options\n\n`jdbc_fdw` accepts the following options via the `CREATE USER MAPPING`\ncommand:\n\n- **username**\n\n  The JDBC username to connect as.\n\n- **password**\n\n\n  The JDBC user's password.\n\n## CREATE FOREIGN TABLE options\n\n`jdbc_fdw` accepts the no table-level options via the\n`CREATE FOREIGN TABLE` command.\n\nThe following column-level options are available:\n\n- **key** as *boolean*\n\n  The primary key options can be set while creating a JDBC foreign table object with OPTIONS(key 'true')\n```\nCREATE FOREIGN TABLE [table name]([column name] [column type] OPTIONS(key 'true')) SERVER [server name];\n```\nNote that while PostgreSQL allows a foreign table to be defined without\nany columns, `jdbc_fdw` *can* raise an error as soon as any operations\nare carried out on it.\n\n\n## IMPORT FOREIGN SCHEMA options\n\n`jdbc_fdw` supports [IMPORT FOREIGN SCHEMA](https://www.postgresql.org/docs/current/sql-importforeignschema.html)\n(when running with PostgreSQL 9.5 or later) and accepts the following custom options:\n\n- **recreate** as *boolean*\n\n  If 'true', table schema will be updated.\nAfter schema is imported, we can access tables.\n\n## TRUNCATE support\n\n`jdbc_fdw` yet don't implements the foreign data wrapper `TRUNCATE` API, available\nfrom PostgreSQL 14.\n\nFunctions\n---------\n\nFunctions from this FDW in PostgreSQL catalog are **yet not described**.\n\n\nIdentifier case handling\n------------------------\n\nPostgreSQL folds identifiers to lower case by default, JDBC data source can have different behaviour.\nRules and problems **yet not tested and described**.\n\nGenerated columns\n-----------------\n\nBehaviour within generated columns **yet not tested and described**. \n\n`jdbc_fdw` potentially can provide support for PostgreSQL's generated\ncolumns (PostgreSQL 12+).\n\nNote that while `jdbc_fdw` will insert or update the generated column value\nin JDBC, there is nothing to stop the value being modified within JDBC,\nand hence no guarantee that in subsequent `SELECT` operations the column will\nstill contain the expected generated value. This limitation also applies to\n`postgres_fdw`.\n\nFor more details on generated columns see:\n\n- [Generated Columns](https://www.postgresql.org/docs/current/ddl-generated-columns.html)\n- [CREATE FOREIGN TABLE](https://www.postgresql.org/docs/current/sql-createforeigntable.html)\n\n\nCharacter set handling\n----------------------\n\n**Yet not described**. JDBC is UTF-8 by default.\n\nExamples\n--------\n\nInstall the extension:\n\n    CREATE EXTENSION jdbc_fdw;\n\nCreate a foreign server with appropriate configuration:\n\n\tCREATE SERVER [server_name] FOREIGN DATA WRAPPER jdbc_fdw\n\t\tOPTIONS(\n\t\t\tdrivername '[JDBC drivername]',\n\t\t\turl '[JDBC url]',\n\t\t\tquerytimeout '[querytimeout]',\n\t\t\tjarfile '[the path of jarfile]',\n\t\t\tmaxheapsize '[maxheapsize]'\n\t\t);\n\nCreate an appropriate user mapping:\n\n    CREATE USER MAPPING FOR CURRENT_USER SERVER [server name] \n    \tOPTIONS(username '[username]',password '[password]');\n\nCreate a foreign table referencing the JDBC table `fdw_test`:\n\n\tCREATE FOREIGN TABLE [table name] (id int) SERVER [server name]);\n\n\nQuery the foreign table.\n\n\tSELECT * FROM [table name];\n\nImport a JDBC schema:\n\n\tIMPORT FOREIGN SCHEMA public\n\t  FROM SERVER [server name]\n\t  INTO public\n\t  OPTIONS (recreate 'true');\n\n\nLimitations\n-----------\n#### Unsupported clause\nThe following clasues are not support in jdbc_fdw:\nRETURNING, GROUPBY, ORDER BY clauses, casting type, transaction control\n\n#### Array Type\nCurrently, jdbc_fdw doesn't support array type.\n\n#### Floating-point value comparison\nFloating-point numbers are approximate and not stored as exact values. A floating-point value as written in an SQL statement may not be the same as the value represented internally.\n\nFor example:\n\n```\nSELECT float4.f1 FROM FLOAT4_TBL tbl06 WHERE float4.f1 \u003c\u003e '1004.3';\n     f1\n-------------\n           0\n      1004.3\n      -34.84\n 1.23457e+20\n 1.23457e-20\n(5 rows)\n```\nIn order to get correct result, can decide on an acceptable tolerance for differences between the numbers and then do the comparison against the tolerance value to that can get the correct result.\n```\nSELECT float4.f1 FROM tbl06 float4 WHERE float4.f1 \u003c\u003e '1004.3' GROUP BY float4.id, float4.f1 HAVING abs(f1 - 1004.3) \u003e 0.001 ORDER BY float4.id;\n     f1\n-------------\n           0\n      -34.84\n 1.23457e+20\n 1.23457e-20\n(4 rows)\n```\n\n#### IMPORT FOREIGN SCHEMA\nCurrently, IMPORT FOREIGN SCHEMA works only with GridDB.\n\nContributing\n------------\nOpening issues and pull requests on GitHub are welcome.\n\nUseful links\n------------\n\n### Source code\n\n - [JDBC\\_FDW](http://github.com/atris/JDBC_FDW.git)\n - [jdbc2\\_fdw](https://github.com/heimir-sverrisson/jdbc2_fdw)\n \n Reference FDW realisation, `postgres_fdw`\n - https://git.postgresql.org/gitweb/?p=postgresql.git;a=tree;f=contrib/postgres_fdw;hb=HEAD\n\n### General FDW Documentation\n\n - https://www.postgresql.org/docs/current/ddl-foreign-data.html\n - https://www.postgresql.org/docs/current/sql-createforeigndatawrapper.html\n - https://www.postgresql.org/docs/current/sql-createforeigntable.html\n - https://www.postgresql.org/docs/current/sql-importforeignschema.html\n - https://www.postgresql.org/docs/current/fdwhandler.html\n - https://www.postgresql.org/docs/current/postgres-fdw.html\n\n### Other FDWs\n\n - https://wiki.postgresql.org/wiki/Fdw\n - https://pgxn.org/tag/fdw/\n \nLicense\n-------\nCopyright (c) 2021, TOSHIBA CORPORATION\nCopyright (c) 2012 - 2016, Atri Sharma atri.jiit@gmail.com\n\nPermission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies.\n\nSee the [`LICENSE`][1] file for full details.\n\n[1]: LICENSE.md \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgspider%2Fjdbc_fdw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgspider%2Fjdbc_fdw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgspider%2Fjdbc_fdw/lists"}