I wanted a quick, light weight database to just run and get started with, HSQLDB satisfied my needs instantly with a delightful approach.
- Download hsqldb-1.9.0-rc6.zip from hsqldb.org's sourceforge.net page.
- Unzip it
- copy hsqldb/sample/server.properties to hsqldb folder (since i am running the server from this directory)
- modify the line server.database.0 file:db0/db0 by replacing db0 to your choice for the database name. example firsttest
- Run the command on a terminal java -cp ./lib/hsqldb.jar org.hsqldb.server.Server
- 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.
- It will give the following output...
[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
- After this try connecting to the database by using the database manager, java -cp ./lib/hsqldb.jar org.hsqldb.util.DatabaseManagerSwing
- 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.
- 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).
- Thats it, next I am going to connect to it with NetBeans.
Thanks, this helped.
Post a Comment