Relational databases are a mainstay of software development, and have been for decades now. It is a rare organization that does not use an RDBMS somewhere, and a rare programmer that does not find herself needing to get data in and out of one at least occasionally. Java has a rich history of quality support for relational databases via JDBC; thanks to its close relationship via the JVM, Clojure easily and fully takes advantage of that history.
We have many options for interacting with relational databases
clojure.java.jdbc is a simple yet
powerful library that acts as a thin layer between Clojure and JDBC.
Korma is another Clojure library that provides a more Clojure-native
interface. And finally, if Clojure’s libraries do not suit your style or
if you are looking to mix Clojure into an existing Java-based
application, you can always fall back to one of the many mature and
robust Java database libraries or frameworks. In this chapter, we’ll
explore setting up and using Hibernate from Clojure.
Whether you use a native Java library or one of
Clojure’s many libraries, connecting to a database in Clojure will
always utilize JDBC, the lowest-level API abstraction for interacting
with relational databases in Java. The
clojure.java.jdbc (https://github.com/clojure/java.jdbc) library wraps
JDBC, so it is easier to use from Clojure:
In terms of dependencies, you need to pair JDBC and