Embedded (pure Java) database for Clojure

北慕城南 提交于 2019-11-28 19:28:45

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)"]))
Alex Miller

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.

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

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.

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/

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!