user149408
user149408

Reputation: 5881

HSQLDB command line tool (sqltool) no longer works on Ubuntu 20.04 and later

On Ubuntu 18.04, I was able to shut down a running HSQLDB instance in server mode with the following one-liner:

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

After upgrading to Ubuntu 20.04 (with HSQLDB 2.4.1 and HSQLDB Utils 2.5.0), this fails with the following error:

Error: Could not find or load main class org.hsqldb.cmdline.SqlTool
Caused by: java.lang.ClassNotFoundException: org.hsqldb.cmdline.SqlTool

Indeed I can no longer find org.hsqldb.cmdline.SqlTool in either of the two JARs, nor any hint at where this functionality has disappeared.

The docs mention sqltool.jar, but I cannot find that file anywhere on my system.

Where has the SqlTool class gone? Or how else can I shut down a running HSQLDB instance from a shell script?

Upvotes: 1

Views: 925

Answers (2)

sxc731
sxc731

Reputation: 2638

Just to expand a little on fredt's answer, here are the actual steps I used to address the issue on my 22.04 (jammy) workstation:

  1. Ascertain which version your system is running with (Jammy seems to ship v2.6.1; substitute 2.6.1 with the appropriate version in the following):

    apt policy libhsqldb-java
    
  2. Download the corresponding version from SourceForge: https://sourceforge.net/projects/hsqldb/files/hsqldb/

  3. Extract /hsqldb-2.6.1/hsqldb/lib/sqltool.jar to /tmp

  4.  sudo -i
     cd /usr/share/java
     mv /tmp/sqltool.jar ./sqltool-2.6.1.jar
     chown root: !$
     ln -s sqltool-2.6.1.jar sqltool.jar
     vi $(type -p hsqldb-sqltool)
    
  5. Add /usr/share/java/sqltool.jar: in CLASSPATH after hsqldb.jar: and exit vi (use nano if you're not comfortable with vi)

  6. Exit your root shell; you can now simply run hsqldb-sqltool

  7. Don't forget to upvote user149408's bug on Launchpad: https://bugs.launchpad.net/ubuntu/+source/hsqldb/+bug/1909811 (login on top-right hand corner; click "This bug affects X person. Does this bug affect you?" link left above ticket).

Upvotes: 3

fredt
fredt

Reputation: 24352

There is no officialy released jar named hsqldbutil.jar. There is an Ant and Gradle build option for that jar which consists of GUI clients.

Download the hsqldb zip package from SourceForge via the download link at http://hsqldb.org

The /lib directory of the zip package contains hsqldb.jar and sqltool.jar. Use these jars in your Java command. This also makes sure you are using the jars from the same release version, as mixing different releases will not function properly.

Upvotes: 2

Related Questions