Getting Clojure/Leiningen to talk to Oracle
06 Sep 2013 →
I’ve just started learning Clojure and have been trying desperately to get my Leiningen project to talk to an Oracle database. All of my enterprise’s data is wrapped up in Oracle, so to do anyting useful or interesting with Clojure, I had to first overcome this step.
The following is surely a no-brainer for experienced Java developers, but I come from Ruby and am new to both Java and Clojure. I hope this helps others coming into Clojure from this angle.
Download Oracle JDBC driver
If you don’t already have an Oracle JDBC driver (ojdbc5.jar, ojdbc6.jar, ojdbc14.jar), you’ll want to download it from Oracle first.
Install ojdbc jar to local Maven repository
Install your JDBC driver to your local Maven repo with this command:
Note a few things here:
groupId
, which would normally be something likecom.oracle
is replaced withlocal
. This can be anything you want;self
orpoo
would work just as well.- Make sure
version
matches the version you downloaded from Oracle. file
needs to point to an absolute path to your jar file. Relative paths don’t seem to work.
Reference your local respository in project.clj
In your project.clj file, you can now specify your proprietary library
as you would any other dependency. Just be sure to prefix it with the
value you used for groupId
in your maven command; local
in this case:
Trying it out
Huzzah! My cheesy query now returns results:
Returns the familiar ol’:
comments powered by Disqus