Date Created: Fri 24-Sep-2010

Related Document Categories:

Get my WebSphere Application Server course here >>

Running the HSQL interactive command line tool

java -jar $HSQLDB_HOME/lib/hsqldb.jar --help

java -jar hsqldb/lib/hsqldb.jar --help

C:\hsqldb_1_8_1_3>java -jar hsqldb/lib/hsqldb.jar --help
Syntax: java org.hsqldb.util.SqlTool [--opt [optval...]] urlid [file1.sql...]
--help Displays this message
--list List urlids in the rc file
--noInput Do not read stdin (default if sql file given
or --sql switch used).
--stdInput Read stdin IN ADDITION to sql files/--sql input
--inlineRc url=val1,user=val2[,charset=val3][,truststore=val4][,password=]
Inline RC file variables (use --driver for driver)
--debug Print Debug info to stderr
--noAutoFile Do not execute auto.sql from home dir
--autoCommit Auto-commit JDBC DML commands
--sql "SQL; Statements" Execute given SQL instead of stdin (before
SQL files if any are specified) where "SQL"
consists of SQL command(s). See the Guide.
--rcFile /file/path.rc Connect Info File [$HOME/sqltool.rc]
--abortOnErr Abort on Error (overrides defaults)
--continueOnErr Continue on Error (overrides defaults)
--setVar NAME1=val1[,NAME2=val2...] PL variables
--driver a.b.c.Driver JDBC driver class [org.hsqldb.jdbcDriver]
urlid ID of url/username/password in rcfile
file1.sql... SQL files to be executed [stdin]
(Use '-' for non-interactively stdin).
See the SqlTool Manual for the supported sqltool.* System Properties.
SqlTool v. 333.


To use a JDBC Driver other than the HSQLDB driver, you can't use the -jar switch because you need to modify the classpath. You must add the hsqldb.jar file and your JDBC driver classes to your classpath, and you must tell SqlTool what the JDBC driver class name is. The latter can be accomplished by either using the "--driver" switch, or setting "driver" in your config file. The RC File Authentication Setup section. explains the second method. Here's an example of the first method (after you have set the classpath appropriately).

I create a bat file called sqltool.bat.

sqltool.bat contains:

java -cp hsqldb/lib/hsqldb.jar org.hsqldb.util.SqlTool --rcFile sqltool.rc event

my sqltool.rc contains:


# A personal, local, persistent database.
urlid event
url jdbc:hsqldb:file:c:\hsqldb\event;shutdown=true
username sa
# When connecting directly to a file database like this, you should
# use the shutdown connection property like this to shut down the DB
# properly when you exit the JVM.

when I run sqltool.bat I get the interactive command line.

Running a select command:

sql> select * from event;
ID                                    NAME              PRIORITY  DATE
------------------------------------  ----------------  --------  --------------
d1f0b9d5-0d24-435f-ad95-25c04dc3e219  Read ZK Tutorial         1  2007-07-24 00:00:00.0


Get my WebSphere Application Server course here >>

Steve Robinson - IBM Champion 2013

About Me

Steve Robinson has been working in IT for over 20 years and has provided solutions for many large-enterprise corporate companies across the world. Steve specialises in Java and Middleware.

In January 2013, I was awarded the prestigous 'IBM Champion' accolade.

  • Linked In
  • Twitter
  • About Me
  • My Blog
  • Contact Me

Read my books?

IBM WebSphere Application Server 8.0 Administration Guide

IBM WebSphere Application Server 8.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Categories

Other Categories