# Java: Database Engines

To use a database system from Java use the JDBC classes, which allow your program to use either a local data base or one located over the Internet.

To package a database engine with your program, you might consider one of the many Java open-source options linked to below.

Because communication with the database is with a standard protocol (JDBC), Java programs can use databases written in any language, so there is no need to restrict your choices to those written in Java.

If you don't want to interact directly with standard SQL, but instead use a more OOP friendly interface that will still use an underlying relational database, you might want to use Hibernate (see below).

## References

- Open Source Database Engines in Java (java-source.net/open-source/database-engines) has an excellent list of databases written in Java. Two of the favorites are.
  - HSQLDB (formerly called Hypersonic SQLDB). This is the database going into version two of Open Office. (hsqldb.sourceforge.net)
  - McKoi. (mckoi.com/database)
- There are many free databases that are not written in Java, but which provide JDBC interfaces. Two top choices are below, but there are many others.
  - PostgreSQL - (www.postgresql.org), Open-source.
  - MySQL - (www.mysql.com), Open-source.
- Hibernate is a very interesting framework that fits between your program and a database, and eases the mismatch between your program's OOP view of the data, and the relational view that is supported by most databases. This is a very popular, well respected, open-source program. (www.hibernate.org).
- jGuru: JDBC 2.0 Fundamentals (java.sun.com/developer/onlineTraining/Database/JDBC20Intro) is a nice introduction to JDBC. A slight problem with this tutorial is that it uses Cloudscape, IBM's former Java database. The only issue is the initial connection to those specific JDBC drivers -- it is otherwise database independent. Altho IBM no longer supports Cloudscape, it has donated it as open source to the the Apache Foundation, where it is now called Derby.