gpt4 book ai didi

java - 如何以编程方式启动 apache derby jar 文件?

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:35:18 24 4
gpt4 key购买 nike

我有一个 Java 应用程序,它使用 Apache Derby。使用 Eclipse 导出选项,我将其导出为 JAR 文件。当我运行 Eclipse 并且服务器连接到端口 1527 时,JAR 正确执行。

但是当 eclipse 关闭时,(并且服务器没有连接到 1527)在执行 jar 时,我得到这个错误

java.sql.SQLNonTransientConnectionException: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused.

这是可以理解的。但我想分发 JAR。那么有没有一种方法可以在每次执行 JAR 时以编程方式启动服务器?

最佳答案

您可以启动 NetworkServer以编程方式:

NetworkServerControl serverControl = new NetworkServerControl(InetAddress.getByName("myhost"),1621)

serverControl.shutdown();

关于java - 如何以编程方式启动 apache derby jar 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9725376/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com