PGCon2018 - 2.5

PGCon 2018
The PostgreSQL Conference

Michael Glaesemann
Day Talks - Day 2: Friday - 2018-06-01
Room DMS 1120
Start time 10:00
Duration 00:45
ID 1224
Event type Lecture
Track DBA

Beyond JDBC

Creating a Custom Postgres driver for Clojure

JDBC is a popular standard database client API for Java. As such, it describes a common denominator for implementations, regardless of any specific backend. Creating a custom driver using the PostgreSQL V3 Protocol can provide access to the rich features PostgreSQL provides beyond those specified by JDBC. This talk will cover one such implementation for Clojure, a Lisp hosted on the JVM.

JDBC is a popular standard database client API for Java. It's great for portability across database server backends, and the PostgreSQL JDBC Driver is a solid implementation. As with many standards, there's an expected common denominator for behavior. There are circumstances, however, when that common denominator limits what's actually available from a specific underlying system. When you want to leverage the full power of Postgres on the JVM, sometimes you need to go beyond what's available with JDBC.

The solution? Implement your own driver! Use the PostgreSQL V3 Protocol to take full advantage of everything PostgreSQL has to offer. In my case, I want a PostgreSQL interface for Clojure---a Lisp hosted on the JVM (as well as compiling to JavaScript)---that is idiomatic to the language. Clojure already has a great wrapper for JDBC, but supporting features such as Clojure's sequence abstraction and data types can be better served by a dedicated driver. In this talk I will cover differences between Java and Clojure and the limitations of the JDBC driver which motivate a new driver for Clojure. In addition, I'll provide an overview of the implementation of the V3 protocol in Clojure, the use of the new driver, and benchmarks comparing it to the current PGJDBC driver.