从Ant /命令行关闭HSQLDB

时间:2023-01-24 13:15:21

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.

我正在尝试编写一个Ant(1.8.2)脚本来从命令行关闭HSQLDB(2.1.0) - 基本上我需要能够从Windows批处理文件中关闭HSQLDB - 在搜索网络后似乎有没有内置的命令行方式 - 如果我错了请纠正我。

I've started the database up with the shipped batch file runServer.bat.

我已经使用随附的批处理文件runServer.bat启动了数据库。

Here is my ant file (shutdown.xml):

这是我的ant文件(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.

classpath是我拥有C:\ programs \ hsqldb \ hsqldb-2.1.0 \ hsqldb \ lib \ hsqldb.jar文件的地方。所有其他细节都是我从Java访问数据库时使用的,他们在那里工作。

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?

但是数据库没有被关闭。它的外壳仍然是开放的。你能看到这里有什么问题吗?

Ant SQL task

Ant SQL任务

Thanks!

谢谢!

1 个解决方案

#1


2  

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.

最好明确命名目标,因为您可以稍后添加额外的目标。您可以使用-verbose选项显示反馈以进行调试。

ant -verbose -buildfile shutdown.xml hsqldb-stop

As the OP found out the jar file name must be included in the command path:

正如OP发现的那样,jar文件名必须包含在命令路径中:

classpath="C:\programs\hsqldb\hsqldb-2.1.0\hsqldb\lib\hsqldb.jar"

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.

java命令中的类路径是目录或jar / zip名称的集合。必须专门指定jar和zip文件的名称,因为这些是包含* .class文件的压缩“目录”。

#1


2  

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.

最好明确命名目标,因为您可以稍后添加额外的目标。您可以使用-verbose选项显示反馈以进行调试。

ant -verbose -buildfile shutdown.xml hsqldb-stop

As the OP found out the jar file name must be included in the command path:

正如OP发现的那样,jar文件名必须包含在命令路径中:

classpath="C:\programs\hsqldb\hsqldb-2.1.0\hsqldb\lib\hsqldb.jar"

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.

java命令中的类路径是目录或jar / zip名称的集合。必须专门指定jar和zip文件的名称,因为这些是包含* .class文件的压缩“目录”。