17

I am developing a Java Desktop Application and want a light database that can be used with Hibernate and that can be packed with an application.

I was going to use Derby database. It's size is near 2 MB. But before that I wanted to have views of experts on SO.

Will it work with Hibernate?

Actually, I am new to Hibernate and was studying that it requires a Dialect for a database so Is Hibernate has dialect for Derby?

Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
Amit
  • 33,847
  • 91
  • 226
  • 299
  • DerbyDialect: https://www.hibernate.org/hib_docs/v3/api/org/hibernate/dialect/DerbyDialect.html – ewernli Mar 12 '10 at 09:43
  • See http://stackoverflow.com/questions/271319/lightweight-sql-database-which-doesnt-require-installation for equivalents in .net world – nawfal Feb 20 '13 at 11:10

4 Answers4

21

JavaDB (Sun's supported distribution of the open source Apache Derby), HSQLDB (not very active) and H2 (the successor of HSQLDB) are all 100% Java embeddable database engines and can all be used with Hibernate (i.e. there are dialect for them). Refer to this page and this one.

HSQLDB has the smallest footprint (~700 KB) of all of them. But feature wise (see this comparison), H2 is the clear winner and its footprint (~1 MB) is still smaller than Derby's one (~2 MB).

The final choice depends on what you need but H2 is a good compromise of features and size (in other words, a big competitor). Have a look at the mentioned comparison.

Maarten Bodewes
  • 90,524
  • 13
  • 150
  • 263
Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
  • Very informative answer.. I am going to use H2 but before that below are few quick questions: 1. Can I embed H2 in my commercial application for free (I checked the site and found that it's free but still want to confirm with you)2. What's your view about SQLLite and Firebird against H2 – Amit Mar 12 '10 at 15:52
  • 5
    @Yatendra 1. Yes you can (http://www.h2database.com/html/license.html) 2. Firebird and SQLite are good products but not 100% Java (i.e. can't run in the same Java process) and this would make things more complex. I'd go for H2. – Pascal Thivent Mar 12 '10 at 16:28
  • I love it , its all I need – RayanFar Jul 19 '16 at 13:25
8

I would recommend HSQLDB. It is small and fast and runs fine with Hibernate. Hibernate has a dialect for the Derby DB as well (haven't used it though and I think it is not officially supported by Hibernate yet).

Daff
  • 43,734
  • 9
  • 106
  • 120
  • I read about HSQLDB. They say that it is in-memory database which doesn't need to be installed and configured. If it remains in the memory, then It should consume a lot of memory for the database server itself and a lot of memory for the data which we will insert into it. May be I interpreted the above statement as wrong but I didn't find much info on the HSQLDB site. I found the above info in Hibernate tutorials. Correct me if am wrong? Also, if it remains in memory, then how the data persist between mulitple runs of the application. – Amit Mar 12 '10 at 13:06
  • 3
    No HSQLDB *can* run as an in memory DB but you can also persist your data on disk (it is basically just a configuration setting). – Daff Mar 12 '10 at 13:27
4

Another Alternative would be SQLite.

Hibernate and SQLite

Aurril
  • 2,469
  • 2
  • 24
  • 38
  • Is there a pure-Java version of SQLite? Or is the native version easy enough to deploy? – Thilo Mar 12 '10 at 10:05
  • 1
    There is one under http://sqljet.com/ or if you don't like this one you can use the following JDBC Driver: http://www.zentus.com/sqlitejdbc/ – Aurril Mar 12 '10 at 10:26
2

You can also try Firebird

There is an embedded version and a client/server mode version

Here an link to hibernate supported database

Hugues Van Landeghem
  • 6,755
  • 3
  • 34
  • 59
  • I would say no. firebird is great, but not as light. A modern embedded firebird with basic minimum required files came abt 6mb without db itself – nawfal May 03 '12 at 22:27