Search code examples
hsqldb

Shut down HSQLDB in server mode from the shell


How can I stop a running HSQLDB server instance from the shell (e.g. as part of a shell script)?


Solution

  • Try the following. Replace dbname with the name of your database and change credentials if necessary, and adjust the classpath to your system as needed:

    java -cp $CLASSPATH:/usr/share/java/hsqldbutil.jar:/usr/share/java/hsqldb.jar "org.hsqldb.cmdline.SqlTool" --inlineRc=url=jdbc:hsqldb:hsql://localhost/dbname,user=SA,password= --sql="SHUTDOWN;"
    

    If your distro comes with a shell script wrapper for SQL Tool, you can shorten that as:

    hsqldb-sqltool --inlineRc=url=jdbc:hsqldb:hsql://localhost/dbname,user=SA,password= --sql="SHUTDOWN;"
    

    Instead of using --inlineRc you can also build an rcfile with the parameters you need and specify that.