Run hsqldb from Eclipse
Introduction
You may be running HSQLDB from an ANT script or a batch file. You can create an Eclipse run configuration to start and stop the HSQLDB server from within Eclipse. As a bonus when you export your project ANT scripts there will be a target created to run the server from ANT.
Project Setup
Add the HSQLDB jar to your project’s classpath. Right click on your project and select properties from the context menu. Choose the Java Build Path item. If you are going to use HSQLDB in many projects it is worth the time to create a variable.
Press the button to get the dialog and then press the button. Then press the button to create a new variable. (You can get there through also.) Make up a descriptive name like HSQLDB 🙂 and then navigate to the location of hsqldb.jar on your filesystem.
Now create a (
) folder in your project. I named mine junkdb.New Run configuration
Choose org.hsqldb.Server
as the main class. Check off “include libraries when searching for a main class”.
If you do not have hsqldb.jar in your project’s classpath you can specify it in your run configuration. Unfortunately you cannot use a classpath variable in your run configuration.
Run configuration 1
Press the arguments tab.
For the program arguments enter
1 |
-database.0 junkdatabase -dbname.0 junkdb |
Uncheck “Use default working directory”. Press the
button and navigate to the empty folder in your project you created previously.Run configuration arguments
Choose the Common tab. You may have to scroll to the right to see it. You can add this run configuration to your “favorites”. When you press the down arrow next to the run icon on the toolbar your favorites are at the top of the menu.
Run configuration options
Go head and run the server now. The console will open and you will see the familiar output. To stop the server just press the red icon.
Console
Refresh your workspace by pressing F5. Look at the contents of your database folder. It’s just internal HSQLDB junk but there they are! The files have the basename you specified in your arguments.