Peter Marklund

Peter Marklund's Home

Mon Jul 13 2015 08:16:06 GMT+0000 (Coordinated Universal Time)

Clojure on Heroku Gotcha - PostgreSQL, Luminus, and JDBC

As I rewrote this blog in Clojure using Luminus one of the main stumbling blocks was getting the PostgreSQL connection working on Heroku. It turned out that the Java DriverManager that the clojure.java.jdbc library talks to can't handle the Heroku DATABASE_URL directly as it contains username and password. However, if you pass the db specification as a string to clojure.java.jdbc/get-connection then the clojure function will parse the database URL for you and pass on the proper credentials on Java. This turns out to be well described in the Heroku documentation (see below) it's just that :connection-uri that the Luminus uses by default (as of this writing) doesn't work on Heroku.