| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
pg-java is a modern, PostgreSQL-specific database driver for the JVM.
Under active development; pre-release and not yet published to Maven Central. The core driver is functional: it connects over plain TCP and TLS, authenticates (including SCRAM-SHA-256 with channel binding), and runs the simple and extended query protocols. A JDBC layer (java.sql.*, registered via java.sql.Driver) is implemented on top of it. The test suite includes integration tests that run against real PostgreSQL (and PgBouncer) via Testcontainers. APIs are still evolving and there are no compatibility guarantees yet. The implementation roadmap (phased, commit-by-commit) lives in docs/plans/overall.md.
The PostgreSQL-native API is the product; nothing in it mentions java.sql. PgConnections.connect returns a PgConnection, and execute returns a pull cursor over the rows:
PgConnectionConfig config = PgConnectionConfig.builder()
.host("localhost", 5432)
.database("appdb")
.user("app")
.password(secret)
.sslMode(SslMode.VERIFY_FULL)
.build();
try (PgConnection connection = PgConnections.connect(config);
PgResultStream rows = connection.execute("select id from t where name = $1", List.of("widget"))) {
while (rows.next()) {
System.out.println(rows.currentRow().getLong(1));
}
}The JDBC layer sits on top of that and registers itself for the jdbc:pg: scheme (ADR-0015), taking libpq-style parameters:
String url = "jdbc:pg://localhost:5432/appdb?user=app&sslmode=verify-full";
try (Connection connection = DriverManager.getConnection(url, "app", secret);
PreparedStatement statement = connection.prepareStatement("select id from t where name = ?")) {
statement.setString(1, "widget");
try (ResultSet rows = statement.executeQuery()) {
while (rows.next()) {
System.out.println(rows.getLong(1));
}
}
}It also answers to jdbc:postgresql: for ported applications, though which driver claims that scheme when real pgjdbc is also on the path is a decision of its own (ADR-0015).
pg-java is a multi-module Maven project. A parent (aggregator) POM ties the modules together. The modules are:
./mvnw clean install(or mvn clean install with a locally installed Maven).
Unit tests run with plain Maven and need no Docker:
mvn testIntegration tests (Testcontainers against a real PostgreSQL, and PgBouncer where relevant) are gated behind the integration-tests profile so the default build stays Docker-free. They require a running Docker daemon:
mvn verify -Pintegration-testsThey default to postgres:17. Selecting another image, sweeping the version matrix, and pointing the suite at an already-running server instead of Docker are covered in AGENTS.md.
See AGENTS.md for project conventions, architecture notes, and guidance for both human and AI contributors.
Please do not report vulnerabilities in a public issue. See SECURITY.md for the private disclosure process, and for the security-relevant defaults that are documented decisions rather than open findings.
pg-java is released under the PostgreSQL License, the same permissive license used by PostgreSQL itself.
The postgresql-client-pgjdbc-compat module deliberately mirrors the public org.postgresql.* API of pgjdbc, which is distributed under the BSD 2-Clause License and, like this project, is copyright the PostgreSQL Global Development Group. See that module's README.md.
| Back | FazBrowse Home | New Git URL |