简体   繁体   English

Clojure的嵌入式(纯Java)数据库

[英]Embedded (pure Java) database for Clojure

I'm in need for an embedded database for a Clojure application. 我需要一个用于Clojure应用程序的嵌入式数据库。 Maybe it's the same criteria as for any other Java application but I rather get some other people's opinion anyway. 也许它与任何其他Java应用程序的标准相同,但我还是得到其他人的意见。 I'm not picking SQLite because that's not pure Java so distribution of a standalone application gets much more complex. 我不是选择SQLite,因为那不是纯Java,因此独立应用程序的分发变得复杂得多。 It seems the way to go is Apache Derby. 似乎要走的路是Apache Derby。 Anything else I should consider? 还有什么我应该考虑的吗?

Without a doubt, H2 毫无疑问, 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: 然后是通常的Clojure SQL代码:

  (with-connection demo-settings 
    (create-table :DEMO_TABLE
           [:M_LABEL "varchar(120)"]
           [:M_DATE "varchar(120)"]
           [:M_COMMENT "varchar(32)"]))

Have you looked at FleetDB ? 你看过FleetDB吗? It's a Clojure database with a JSON protocol and clients in several languages. 它是一个带有JSON协议的Clojure数据库和多种语言的客户端。 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. 我在clojure中使用了嵌入式数据库H2,并使用clojureQL来访问它。 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 但请注意,由于数据库正在进行中,因此您不应将此用于大量记录(单个表中超过10,000个),因为您将遇到巨大的性能问题,因为数据库和您的代码将共享相同的JVM

我认为Derby是一个出色的100%Java嵌入式数据库,它对各种各样的应用程序非常有用,由活跃的社区维护得很好,并且有很好的文档记录。

我正在使用https://github.com/clojurewerkz/archimedes ,它允许您稍后指定后端。

If you don't mind NOSQL, neo4j is an embeddable graph db with transactions, licensed under the GPL. 如果你不介意NOSQL,neo4j是一个带有事务的嵌入式图形数据库,根据GPL许可。 The most up to date bindings I've found are https://github.com/hgavin/borneo 我发现的最新绑定是https://github.com/hgavin/borneo

There is also an interesting graph db project in clojure with pluggable backends: https://github.com/flatland/jiraph 在clojure中还有一个有趣的图形数据库项目,带有可插拔的后端: 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 仍然相当年轻但看起来很有前景的OrientDB可能值得一看: http//www.orientechnologies.com/orient-db.htm

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

Then there's http://jdbm.sourceforge.net/ 那就是http://jdbm.sourceforge.net/

另一个需要考虑的选择是键值存储Chronicle Map ,因为它是纯Java并提供了一个vanilla Java Map接口,因此使用Clojure时使用它应该非常简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM