Supply password to HSQLDB SqlTool in a script2020-05-17 hsqldb
I am running an HSQLDB instance in server mode as a systemd service. To shut it down, I issue the following command:
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=`cat ~/SA.pwd` --sql="SHUTDOWN;"
As one can see in the command, I connect as user SA with a password read from a file (which only that particular user can read), and specify both in the JDBC URL.
This works as long as SA has an empty password and I just supply
password= in the command.
However, if SA has a real password and I supply it here, this fails with the error message:
'password' element must have empty value. For non-empty password, give no password element and you will be prompted for the value.
Is there any way to supply the password in a non-interactive way?
It works if you use a
sqltool.rc file instead of
--inline-rc. Place a file with the following contents in the home folder of the account which will be issuing the stop command:
urlid my-server url jdbc:hsqldb:hsql://localhost/db_name username SA password CorrectHorseBatteryStaple
Then modify the command line as follows:
java -cp $CLASSPATH:/usr/share/java/hsqldbutil.jar:/usr/share/java/hsqldb.jar "org.hsqldb.cmdline.SqlTool" --sql="SHUTDOWN;" my-server
my-serveris an arbitrary identifier that you define in
sqltool.rcand quote in the command line invocation of SqlTool
db_nameis the database name assigned at startup
CorrectHorseBatteryStapleis the SA password (as currently stored in
Change these as appropriate for your system. As
sqltool.rc contains credentials, be sure to lock down its permissions as you would for
- Multiple Java Applications accessing one HSQLDB causes app to hang
- RazorSQL causes HSQLDB to throw org.hsqldb.HsqlException: Client driver version greater than '184.108.40.206' is required. HSQLDB server version is '2.3.4'
- how to connect to a file based HSQLDB database with sqltool?
- Database lock Acquisition file when trying to install and configure HSQLDB
- Stored Procedure in HSQLDB. Creation through SQLTool
- How to ensure HSQLDB properties configuration loaded on Windows?
- Shutdown Hsqldb server when no more clients are connected
- SQLTool does not commit data after quit (HSQLDB)
- HSQLDB startup DDL script