Embedded (pure Java) database for Clojure
Asked Answered
J

8

18

I'm in need for an embedded database for a Clojure application. Maybe it's the same criteria as for any other Java application but I rather get some other people's opinion anyway. I'm not picking SQLite because that's not pure Java so distribution of a standalone application gets much more complex. It seems the way to go is Apache Derby. Anything else I should consider?

Juniper answered 3/8, 2011 at 6:7 Comment(1)
Looking forward to the answers on this one. I've used HSQLDB in Java more than Derby, but only for unit tests. Interested to see if anyone has used FleetDB as it has a Clojure client....Carillo
M
28

Without a doubt, H2

Here are the settings,

 (def demo-settings
   {
    :classname   "org.h2.Driver"
    :subprotocol "h2:file"
    :subname     (str (System/getProperty "user.dir") "/" "demo")
    :user        "sa"
    :password    ""
   }
  )

And then the usual Clojure SQL code:

  (with-connection demo-settings 
    (create-table :DEMO_TABLE
           [:M_LABEL "varchar(120)"]
           [:M_DATE "varchar(120)"]
           [:M_COMMENT "varchar(32)"]))
Maddalena answered 3/8, 2011 at 6:43 Comment(1)
Definitely H2 for me too. It has worked well for me with the clojureql query library. There is one required work-around for H2 with clojureql, H2 doesn't have the JOIN USING syntax supported when last I checked, you have to use the more verbose JOIN ON equivalent.Joshia
P
4

Have you looked at FleetDB? It's a Clojure database with a JSON protocol and clients in several languages. I suspect you could probably run it embedded without working too hard at it.

Parathyroid answered 7/8, 2011 at 17:47 Comment(0)
W
3

h2

oracle Berkley DB

Warrigal answered 3/8, 2011 at 6:45 Comment(0)
D
2

I used an embedded database, H2 within clojure and used clojureQL to access it. Be warned though that since the database is in process you should not use this for large amounts of records (> than 10,000s in a single table) as you will get huge performance problems as the database and your code will both be sharing the same JVM

Dustin answered 5/8, 2011 at 20:27 Comment(0)
S
2

I think Derby makes an excellent 100% Java embedded database, and it's useful for a wide variety of applications, well-maintained by an active community, and very well documented.

Selfreliant answered 11/8, 2011 at 14:3 Comment(0)
P
1

If you don't mind NOSQL, neo4j is an embeddable graph db with transactions, licensed under the GPL. The most up to date bindings I've found are https://github.com/hgavin/borneo

There is also an interesting graph db project in clojure with pluggable backends: https://github.com/flatland/jiraph

The still quite young but promising looking OrientDB might be worth a look: http://www.orientechnologies.com/orient-db.htm

http://github.com/eduardoejp/clj-orient

Then there's http://jdbm.sourceforge.net/

Precondemn answered 28/8, 2011 at 22:14 Comment(0)
P
1

I am using https://github.com/clojurewerkz/archimedes which allows you to specify a backend later.

Posterior answered 30/1, 2014 at 19:28 Comment(0)
G
0

Another option to consider is a key-value store Chronicle Map, because it's pure Java and provides a vanilla Java Map interface, so working with it should be very simple using Clojure.

Griffy answered 8/7, 2016 at 17:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.