3

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?
Oliv
  • 10,221
  • 3
  • 55
  • 76
troc
  • 379
  • 2
  • 4
  • 16

2 Answers2

17

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 native libraries inside the driver. Typically the JDBC driver talks to a remote database.

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.

Gray
  • 115,027
  • 24
  • 293
  • 354
  • 1
    "The Xerial driver actually is simulating the Sqlite C code in a little VM -- strange but it seems to work well" - *really*? As far as i can tell, it isn't doing that now. Was that how it worked when you wrote that? – Tom Anderson Apr 02 '20 at 11:09
  • I'm not sure where I got that @TomAnderson but I can't find anything that references it so maybe I was suffering from a head wound at the time. I've edited that section. Thanks for the pushback. – Gray Apr 02 '20 at 14:15
  • Oh, that's a shame. I was hoping they had some amazing implementation in the past! – Tom Anderson Apr 02 '20 at 16:50
2
  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.

jayunit100
  • 17,388
  • 22
  • 92
  • 167