A new JDBC driver for PostgreSQL, pg-java, is in pre-release, authored by Sehrope Sarkini (with assistance from Claude). The project's philosophy is PostgreSQL-first: the native API is designed around PostgreSQL's wire protocol and feature set, not the lowest common denominator imposed by cross-database JDBC compliance. This foundational approach reshapes how Java developers interact with PostgreSQL.
Key Features and Changes
- PostgreSQL-Centric Native API: The native API directly expresses PostgreSQL-specific capabilities, avoiding the constraints of generic JDBC abstractions. If PostgreSQL supports a feature, the API aims to articulate it natively.
- JDBC as a Compatibility Layer: Full JDBC compliance is a long-term goal. The existing
java.sql.*layer providesDriver,Connection,PreparedStatement,ResultSet,DatabaseMetaData,DataSource, andXAclasses, but these are built on top of the native API, not dictating its design. This ordering prevents JDBC assumptions from polluting the execution core. - Virtual Threads for I/O: On Java 21 and later, pg-java uses virtual threads for I/O, eliminating the traditional thread-per-connection overhead. The driver uses ordinary blocking-style code, carefully avoiding carrier thread pinning (e.g.,
ReentrantLockinstead ofsynchronizedaround I/O), enabling thousands of connections on a single carrier thread. - Pre-Release Status: As a pre-release, developers are encouraged to test and provide feedback, but production use should be cautious.
This driver matters because it breaks from the historical trade-off between synchronous simplicity and high concurrency. For a decade, reactive or async APIs were necessary for scalability, but with virtual threads, pg-java offers a clean, synchronous API that scales. Moreover, its PostgreSQL-first design ensures that advanced features like COPY, LISTEN/NOTIFY, and native JSON support are first-class citizens, not afterthoughts. For Java developers, this could mean a simpler, more idiomatic way to harness the full power of PostgreSQL. The project is open source, and its repository is available for community exploration.
Source: https://www.postgresql.org/about/news/new-modern-jdbc-driver-for-postgresql-3354/