Search code examples
databaseclojurederbyembedded-database

Embedded (pure Java) database for Clojure


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?


Solution

  • 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)"]))