Sep 23, 2009

HSQLDB Setup made simple

I wanted a quick, light weight database to just run and get started with, HSQLDB satisfied my needs instantly with a delightful approach.
  1. Download hsqldb-1.9.0-rc6.zip from hsqldb.org's sourceforge.net page.
  2. Unzip it
  3. copy hsqldb/sample/server.properties to hsqldb folder (since i am running the server from this directory)
  4. modify the line server.database.0 file:db0/db0 by replacing db0 to your choice for the database name. example firsttest
  5. Run the command on a terminal java -cp ./lib/hsqldb.jar org.hsqldb.server.Server
  6. Notice that I haven't included any alias for the server, nor any -database.0 properties since they are being picked up from the server.properties file.
  7. It will give the following output...

  8. [Server@7ecec0c5]: [Thread[main,5,main]]: checkRunning(false) entered
    [Server@7ecec0c5]: [Thread[main,5,main]]: checkRunning(false) exited
    [Server@7ecec0c5]: Startup sequence initiated from main() method
    [Server@7ecec0c5]: Loaded properties from [/{PATH}/hsqldb/server.properties]
    [Server@7ecec0c5]: Initiating startup sequence...
    [Server@7ecec0c5]: Server socket opened successfully in 8 ms.
    [Server@7ecec0c5]: Database [index=0, id=0, db=file:firsttest/firsttest, alias=] opened sucessfully in 393 ms.
    [Server@7ecec0c5]: Startup sequence completed in 402 ms.
    [Server@7ecec0c5]: 2009-09-23 01:32:09.766 HSQLDB server 1.9.0 is online on port 9001
    [Server@7ecec0c5]: To close normally, connect and execute SHUTDOWN
    SQL[Server@7ecec0c5]: From command line, use [Ctrl]+[C] to abort abruptly

  9. After this try connecting to the database by using the database manager, java -cp ./lib/hsqldb.jar org.hsqldb.util.DatabaseManagerSwing

  10. A window will open like the one above, enter the parameters like the one above and we should be connected to the server. Once connected we can use the menu options to create tables. You have to know SQL syntax. Since we didn't give any alias the URL is up until localhost only.
  11. pressing Ctrl C will shutdown the database. This mode of the server is persistent, hence if we start the server again, the changes are there and can be verified in the DatabaseManager (which of course has to be reconnected with the server).
  12. Thats it, next I am going to connect to it with NetBeans.
shubhanan said...

Thanks, this helped.

shubhanan said...
This comment has been removed by the author.

Whatsapp Button works on Mobile Device only

Start typing and press Enter to search