Friday, August 3, 2007

Using HSQLDB database - the basics

HSQLDB is a powerful database engine. It is normally used to provided an embedded database functionality for java applications.

It is as simple as downloading a zip file, extracting it into your system and you have a functioning RDBMS.

After extracting the zip file, you should have the following (resumed) structure in your system:

/bin (scripts for running the server and utilities)
/demo (scripts and applet examples)
/doc (guess what?)
/lib (all binaries - including hsqldb.jar)
/src (all source code)
index.html (documentation about the distribution)

The hsqldb.jar is everything you need to run the database application. It contains the RDBMS, the driver and some tools (the database manager, the query tool and the command line tool).

Running the tools

To run some of the tools, enter the lib folder and run the following command, which will run the database manager.

java -cp hsqldb.jar org.hsqldb.util.DatabaseManager

The main classes for the tools deployed with the hqsldb.jar are:

  • org.hsqldb.util.DatabaseManager

  • org.hsqldb.util.DatabaseManagerSwing

  • org.hsqldb.util.Transfer

  • org.hsqldb.util.QueryTool

  • org.hsqldb.util.SqlTool

HSQLDB may run in standalone (in-process) or server mode. There are three server modes, based on the protocol used for communications between the client and server and they are HSQLDB Server, Web Server and Servlet. It is also possible to run HSQLDB in a way that the database is not persistent and exists entirely in random access memory.

The default user and password for connecting to the database is "sa" / "sa".

For more information on this powerful tool, read the online manuals or the documentation provided with the distribution zip file in the doc folder.