Java 嵌入式数据库比较
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/462923/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java Embedded Databases Comparison
提问by Hosam Aly
I intend to develop a small (Java) application for managing my finances. I believe I need to use an embedded database, but I have no experience regarding this issue. I tried to look at some of the available products, but I can't decide which one would be more suitable for me. H2, HSQLDB, Derbyand Berkeley DBseem to be good candidates, but I still don't see how they compare to each other. I appreciate your help comparing them and helping me decide which one to use.
我打算开发一个小型(Java)应用程序来管理我的财务。我相信我需要使用嵌入式数据库,但我对这个问题没有经验。我试图查看一些可用的产品,但我无法决定哪一种更适合我。H2、HSQLDB、Derby和Berkeley DB似乎是不错的候选者,但我仍然看不出它们之间的比较。感谢您帮助比较它们并帮助我决定使用哪个。
I intend to use Hibernate for my application (unless you would recommend using DBMS-provided API), but I also want to have the ability to edit the database easily using a SQL browsing tool (modifying schema and changing data).
我打算将 Hibernate 用于我的应用程序(除非您建议使用 DBMS 提供的 API),但我也希望能够使用 SQL 浏览工具(修改架构和更改数据)轻松编辑数据库。
Thank you.
谢谢你。
采纳答案by Sven Lilienthal
Either
任何一个
- HSQLDB- Used by OpenOffice, tested and stable. It's easy to use. If you want to edit your db-data, you can just open the file and edit the insert statements.
- HSQLDB- 由 OpenOffice 使用,经过测试且稳定。它很容易使用。如果要编辑 db-data,只需打开文件并编辑插入语句即可。
or
或者
- H2- Said to be faster (by the developer, who originally designed hsqldb, too)
- H2- 据说更快(由最初设计 hsqldb 的开发人员提供)
Which one you use is up to you, depending how much performance and how much stability you need.
您使用哪一种取决于您,取决于您需要多少性能和多少稳定性。
The developer of H2 has put up a nice performance evaluation:
http://www.h2database.com/html/performance.html
H2的开发者给出了不错的性能评测:http:
//www.h2database.com/html/performance.html
回答by Kilhoffer
I am a big fan of DB4O for both .Net and Java.
我是.Net 和 Java的DB4O 的忠实粉丝。
Performance has become much better since the early releases. The licensing model isnt too bad, either. I particularly like the options available for querying your objects. Query by example is very powerful and easy to get used to.
自早期版本以来,性能已经变得更好。许可模式也不错。我特别喜欢可用于查询对象的选项。示例查询非常强大且易于使用。
回答by Jason Cohen
We use HSQLDB in production as a "no-configuration" option for our application. It allows people to trial without the hassle of setting up a real database.
我们在生产中使用 HSQLDB 作为我们应用程序的“无配置”选项。它允许人们进行试用,而无需设置真实的数据库。
However we do notsupport it for normal use. The reasons are several:
但是我们不支持它正常使用。原因有几个:
- Slows down proportionally to the size of the data.
- Difficult to access outside of our app (e.g. for custom reports).
- Transactions / disk-sync is difficult to get right, so it's easy to lose data.
- 根据数据大小按比例减慢。
- 难以在我们的应用程序之外访问(例如自定义报告)。
- 事务/磁盘同步很难正确,因此很容易丢失数据。
For at least (2) and (3), there are ways around it but it's difficult; it's much easier to e.g. install MySQL.
至少对于 (2) 和 (3) 来说,有办法绕过它,但很难;例如安装MySQL要容易得多。
回答by Stu Thompson
Java DB(Sun's distribution of Apache Derby) now ships inJDK 6!
Java DB(Sun 的 Apache Derby 发行版)现在包含在JDK 6 中!
I've been wanted to do something like Jason Cohen and have been thinking this looks like the easiest way being in the JDK distro (which of last week is now a requirement for my app). Or maybe I am just lazy that way.
我一直想做类似 Jason Cohen 的事情,并且一直认为这看起来是 JDK 发行版中最简单的方法(上周我的应用程序要求使用它)。或者也许我只是那样懒惰。
回答by Chris Dail
I use Apache Derbyfor pretty much all of my embedded database needs. You can also use Sun's Java DB that is based on Derby but the latest version of Derby is much newer. It supports a lot of options that commercial, native databases support but is much smaller and easier to embed. I've had some database tables with more than a million records with no issues.
我使用Apache Derby来满足我几乎所有的嵌入式数据库需求。您还可以使用基于 Derby 的 Sun 的 Java DB,但最新版本的 Derby 要更新得多。它支持许多商业原生数据库支持的选项,但体积更小,更易于嵌入。我有一些数据库表有超过一百万条记录,没有问题。
I used to use HSQLDB and Hypersonic about 3 years ago. It has some major performance issues at the time and I switch to Derby from it because of those issues. Derby has been solid even when it was in incubator at Apache.
大约 3 年前,我曾经使用过 HSQLDB 和 Hypersonic。当时它有一些主要的性能问题,由于这些问题,我从它切换到了 Derby。即使在 Apache 的孵化器中,Derby 也很稳定。
回答by Telcontar
I have used Derby and i really hate it's data type conversion functions, especially date/time functions. (Number Type)<--> Varchar conversion it's a pain.
我使用过 Derby,我真的很讨厌它的数据类型转换函数,尤其是日期/时间函数。(数字类型)<--> Varchar 转换很痛苦。
So that if you plan use data type conversions in your DB statements consider the use of othe embedded DB, i learn it too late.
因此,如果您计划在 DB 语句中使用数据类型转换,请考虑使用其他嵌入式 DB,我了解它为时已晚。
回答by devstopfix
neo4jis:
neo4j是:
an embedded, disk-based, fully transactional Java persistence engine that stores data structured in graphs rather than in tables
一个嵌入式的、基于磁盘的、完全事务性的 Java 持久性引擎,用于存储以图形而非表格结构化的数据
I haven't had a chance to try it yet - but it looks very promising. Note this is not an SQL database - your object graph is persisted for you - so it might not be appropriate for your existing app.
我还没有机会尝试它 - 但它看起来很有希望。请注意,这不是 SQL 数据库 - 您的对象图已为您保留 - 因此它可能不适合您现有的应用程序。
回答by Fabian Steeg
I realize you mentioned SQL browsing, but everything else in your question makes me want to suggest you also consider DB4O, which is a great, simple object DB.
我知道您提到了 SQL 浏览,但是您问题中的其他所有内容都让我想建议您也考虑DB4O,这是一个很棒的简单对象 DB。
回答by Joachim Sauer
I personally favor HSQLDB, but mostly because it was the first I tried.
我个人喜欢 HSQLDB,但主要是因为它是我尝试的第一个。
H2 is said to be faster and provides a nicer GUI frontend (which is generic and works with any JDBC driver, by the way).
据说 H2 速度更快,并提供了更好的 GUI 前端(顺便说一下,它是通用的并且适用于任何 JDBC 驱动程序)。
At least HSQLDB, H2 and Derby provide server modes which is great for development, because you can access the DB with your application and some tool at the same time (which embedded mode usually doesn't allow).
至少 HSQLDB、H2 和 Derby 提供了非常适合开发的服务器模式,因为您可以同时使用应用程序和某些工具访问数据库(嵌入式模式通常不允许)。
回答by Wookai
HSQLDBis a good candidate (the fact that it is used in OpenOffice may convinced some of you), but for such a small personnal application, why not using an object database (instead of a classic relationnal database) ?
HSQLDB是一个不错的选择(OpenOffice 中使用它的事实可能会让你们有些人信服),但是对于如此小的个人应用程序,为什么不使用对象数据库(而不是经典的关系数据库)?
I used DB4Oin one of my projects, and I'm very satisfied with it. Being object-oriented, you don't need the whole Hibernate layer, and can directly insert/update/delete/query objects ! Moreover, you don't need to worry about the schema, you directly work with the objects and DB4O does the rest !
我在我的一个项目中使用了DB4O,对此我非常满意。面向对象,不需要整个Hibernate层,可以直接插入/更新/删除/查询对象!此外,您无需担心模式,您可以直接使用对象,其余的由 DB4O 完成!
I agree that it may take some time to get used to this new type of database, but check the DB40 tutorialto see how easy it makes working with the DB !
我同意可能需要一些时间来适应这种新型数据库,但请查看DB40 教程,了解它使使用 DB 变得多么容易!
EDIT: As said in the comments, DB4O handles automatically the newer versions of the classes. Moreover, a tool for browsing and updating the database outside of the application is available here : http://code.google.com/p/db4o-om/
编辑:正如评论中所说,DB4O 会自动处理这些类的较新版本。此外,此处提供了用于在应用程序之外浏览和更新数据库的工具:http: //code.google.com/p/db4o-om/