如何以编程方式启动 apache derby jar 文件? [英] How can I start apache derby programmatically jar file?

查看:21
本文介绍了如何以编程方式启动 apache derby jar 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a Java application, which uses Apache Derby. Using Eclipse Export option, I exported it as JAR file. When I am running Eclipse, and the server is connected to port 1527, the JAR executes correctly.

但是,当 Eclipse 关闭时(并且服务器未连接到 1527),在执行 jar 时,我收到此错误

However when eclipse is closed, (and the server is not connected to 1527) on executing jar, i get this error

java.sql.SQLNonTransientConnectionException: java.net.ConnectException: 在端口 1527 上连接到服务器本地主机时出错,并显示消息连接被拒绝.

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

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

This is understandable. But i want to distribute the JAR. So is there a way to start the server programmatically, whenever JAR is executed?

推荐答案

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

You can start the NetworkServer programmatically:

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

serverControl.shutdown();

这篇关于如何以编程方式启动 apache derby jar 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆