java SQLite 是否最适合用于嵌入式数据库?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11639256/
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
Is SQLite the most appropriate thing to use for an embedded database?
提问by troc
I need to build a Java application that I will install on a Linux server.
我需要构建一个将安装在 Linux 服务器上的 Java 应用程序。
When people will install they just would need to install this application, launch it, and nothing more. But we have some data to save.
当人们安装时,他们只需要安装这个应用程序,启动它,仅此而已。但是我们有一些数据要保存。
- I said no to MySQL, because it needs a server.
- I said no to XML because there will be really a lot of data to save and manipulate.
- 我对 MySQL 说不,因为它需要一个服务器。
- 我对 XML 说不,因为确实有很多数据需要保存和操作。
So I'm looking at SQLite which is the best I think. Indeed (stop me if i'm wrong), SQLite doesn't need any server? (just install the final application and SQLite works fine in my application?)
所以我在看 SQLite,这是我认为最好的。确实(如果我错了就阻止我),SQLite 不需要任何服务器?(只需安装最终的应用程序,SQLite 就可以在我的应用程序中正常工作?)
Then I checked at http://www.sqlite.org/cvstrac/wiki?p=SqliteWrappersand I'm really a little bit confused.
然后我查看了http://www.sqlite.org/cvstrac/wiki?p=SqliteWrappers,我真的有点困惑。
- What is the difference between a Wrapper and a Driver?
- Plus I see there exists a "pure java implementation": SQLJet is it more or less optimized?
- Finally what would you use in my situation?
- 包装器和驱动程序有什么区别?
- 另外,我看到存在一个“纯 Java 实现”:SQLJet 是或多或少优化了?
- 最后你会在我的情况下使用什么?
回答by Gray
Another database to consider is H2. It is an embedded database engine completely written in Java so you have the benefit of full unicode (16 bit) character support that Sqlite does nothave. Other embedded databases are HSQLDBand Derby.
另一个要考虑的数据库是H2。这是完全用Java编写的,所以你有充分的Unicode的利益嵌入式数据库引擎(16位)字符支持,SQLite的确实不具备。其他嵌入式数据库是HSQLDB和Derby。
sqlite doesnt need any requirement on the server ?
sqlite 不需要对服务器的任何要求?
Correct. It does not. Neither does H2.
正确的。它不是。H2也不行。
just install the final application and sqlite works fine in my application ?
只需安装最终的应用程序,sqlite 就可以在我的应用程序中正常工作吗?
Correct. As long as you include Sqlite or H2 in your WAR (or unpack it into your jar), it will work fine.
正确的。只要您在 WAR 中包含 Sqlite 或 H2(或将其解压到 jar 中),它就可以正常工作。
What is the difference between a Wrapper and a Driver ?
Wrapper 和 Driver 和有什么不一样?
Depends on the usage. I think Sqlite is talking about the fact that when you use the JDBC driver for Sqlite, it is actually a wrapping of the Sqlite C native libraries inside the driver. Typically the JDBC driver talks to a remote database.
取决于使用情况。我认为 Sqlite 是在谈论这样一个事实,即当您为 Sqlite 使用 JDBC 驱动程序时,它实际上是驱动程序内部对 Sqlite C 本机库的包装。通常,JDBC 驱动程序与远程数据库对话。
H2 also is that way with the "driver" actually doing the database operations just that it was written in Java so you don't need the C wrapper.
H2 也是这样,“驱动程序”实际上执行数据库操作,只是它是用 Java 编写的,因此您不需要 C 包装器。
Plus I see there exists a "pure java implementation" : SQLJet is it more or less optimized?
另外,我看到存在一个“纯 Java 实现”:SQLJet 或多或少优化了?
This is the first I've heard of Sqljet so I'm not sure. The Xerial Sqlite driveris what I've used and it's performance seems to be good.
这是我第一次听说 Sqljet,所以我不确定。该Xerial sqlite的驱动程序是什么,我已经用它的表现似乎也不错。
Finally what would you use in my situation?
最后你会在我的情况下使用什么?
I'd use H2 myself for the native Java features.
我自己将 H2 用于本机 Java 功能。
回答by jayunit100
Yes SQLite doesn't require a server.
One very simple solution for development is using SQLLite by embedding it in your source code, with a little stub data. You can then commit your database to your version control system (i.e. I use github, its super easy to do this) as a single file. This is, obviously, not a good production method, but it is a good way to create a single development version.
A Wrapper is a program which facades another program by allowing you to access its functionality through a different interface. For example, eclipse "wraps" many java programs that we use in everyday development for us in a convenient GUI. Whereas a Driver is a program that is needed to launch an existing application. For example, in a java application, we might have a main class that can be thought of as a Driver for entry point to the application.
是的 SQLite 不需要服务器。
一个非常简单的开发解决方案是使用 SQLLite,将它嵌入到您的源代码中,并带有少量存根数据。然后您可以将您的数据库作为单个文件提交到您的版本控制系统(即我使用 github,它非常容易做到)。显然,这不是一个好的生产方法,但它是创建单一开发版本的好方法。
Wrapper 是一个程序,它通过允许您通过不同的界面访问另一个程序的功能来外观另一个程序。例如,eclipse 为我们在一个方便的 GUI 中“包装”了许多我们在日常开发中使用的 Java 程序。而驱动程序是启动现有应用程序所需的程序。例如,在 Java 应用程序中,我们可能有一个主类,可以将其视为应用程序入口点的驱动程序。