Is SQLite the most appropriate thing to use for an

2019-02-11 01:56发布

This question already has an answer here:

I need to build a Java application that I will install on a Linux server.

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.

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?)

Then I checked at http://www.sqlite.org/cvstrac/wiki?p=SqliteWrappers and I'm really a little bit confused.

  • 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 sqlite h2
2条回答
小情绪 Triste *
2楼-- · 2019-02-11 02:46

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 not have. Other embedded databases are HSQLDB and Derby.

sqlite doesnt need any requirement on the server ?

Correct. It does not. Neither does H2.

just install the final application and sqlite works fine in my application ?

Correct. As long as you include Sqlite or H2 in your WAR (or unpack it into your jar), it will work fine.

What is the difference between a Wrapper and a 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 code inside of the driver. Typically the JDBC driver talks to a remote database. The Xerial driver actually is simulating the Sqlite C code in a little VM -- strange but it seems to work well.

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.

Plus I see there exists a "pure java implementation" : SQLJet is it more or less optimized?

This is the first I've heard of Sqljet so I'm not sure. The Xerial Sqlite driver is what I've used and it's performance seems to be good.

Finally what would you use in my situation?

I'd use H2 myself for the native Java features.

查看更多
小情绪 Triste *
3楼-- · 2019-02-11 02:49
  1. Yes SQLite doesn't require a server.

  2. 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.

  3. 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.

查看更多
登录 后发表回答