These tutorials are no longer maintained. Some of these tutorials continue to be maintained for the lecture Advanced Concepts in Software Engineering.
Preconditions
- Make sure Eclipse with JBoss Tools Plug-in is installed properly (tutorial).
- HSQLDB’s connection string should include
shutdown=true
on WildFly to ensure the database is closed correctly. This is needed to overcome the limitation of in-process HSQLDBs supporting just one, its creating, thread. - Alternatively (No need to stop WildFly server): Start HSQLDB as a dedicated instance and change JDBC connection strings accordingly.
Creating a Database Connection for In-Process HSQLDB
- Open the “Data Source Explorer” view using Window > Show view > Other and create a new Database Connection.
- Choose HSQLDB from the list of Connection Profile Types and provide a name, e.g. Library.
-
Next, add a New Driver Definition and specify hsqldb.jar in the JAR List tab.
- Enter the database name and specify the location of the database files, e.g.
file:/tmp/wildfly/standalone/data/hypersonic/localDB
.
Creating a Database Connection for Dedicated HSQLDB
- Start a dedicated instance by executing the following on a shell:
java -cp ~/Downloads/hsqldb.jar org.hsqldb.server.Server --database.0 file:localDB --dbname.0 localDB
- Adjust Java’s classpath (
-cp
) to match the location ofhsqldb.jar
on your system database.0
: the location where the database is storeddbname.0
: remote name/database name for the database
- Adjust Java’s classpath (
- Perform steps 1-3 of In-Process HSQLDB (they also apply when using a dedicated HSQLDB).
- Enter the the database name and specify the address/location of HSQLDB, e.g.
hsql://localhost/localDB
.
For the dedicated HSQLDB instance to be used by deployed applications, you need to adjust the corresponding datasource to connect to it. Go to the Wildfly Console and change the Connection URL to jdbc:hsqldb:hsql://localhost/localDB
, so that it matches your previously defined database name.
Accessing HSQLDB
HSQLDB Database Manager
- Execute the following on a shell:
java -cp path-to-your-hsqldb/hsqldb.jar org.hsqldb.util.DatabaseManagerSwing
- Connect to the HSQLDB server.
- Type: HSQL Database Engine Server
- Driver: org.hsqldb.jdbcDriver
- URL: jdbc:hsqldb:hsql://localhost/localDB (adjust to match your database name)
- User: sa
- Perform queries on HSQLDB.
SQL Scrapbook
- In-Process HSQLDB only: Stop WildFly to shutdown HSQLDB.
- Right-click on connection and select “Connect”.
- Right-click on connection and select “Open SQL Scrapbook”.
- Perform queries on HSQLDB.
- In-Process HSQLDB only: Right-click on connection and select “Disconnect”, before starting WildFly again.