I am trying to write an Ant (1.8.2) script to shutdown HSQLDB (2.1.0) from the command line – basically I need to be able to shutdown HSQLDB from a Windows batch file – after searching the web it seems like there is no built-in command line way to do it – please correct me if I am wrong.
I’ve started the database up with the shipped batch file runServer.bat.
Here is my ant file (shutdown.xml):
<project>
<target name="hsqldb-stop">
<sql
classpath="C:\programs\hsqldb\hsqldb-2.1.0\hsqldb\lib"
driver="org.hsqldb.jdbcDriver"
url="jdbc:hsqldb:hsql://localhost:9001"
userid="sa" password=""
autocommit="true">SHUTDOWN</sql>
</target>
</project>
classpath is where I have the C:\programs\hsqldb\hsqldb-2.1.0\hsqldb\lib\hsqldb.jar file.
All the other details are those that I use when I access the database from Java, and they do work there.
When I run it I get:
>ant -buildfile shutdown.xml
Buildfile: shutdown.xml
BUILD SUCCESSFUL
Total time: 0 seconds
HOWEVER the database is not being shutdown. Its shell is still open.
Can you see what is wrong here?
Thanks!
It is better to name the target explicitly, as you may add extra targets later on. You can show feedback with the -verbose option for debugging.
As the OP found out the jar file name must be included in the command path:
The classpath in a java command is a collection of directory or jar / zip names. The names of jars and zip files must be specified specifically, as these are the compressed “directories” that contain the *.class files.