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

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

问题描述

我有一个Java应用程序,它使用Apache Derby。使用Eclipse Export选项,我将其导出为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上的服务器localhost,消息
连接被拒绝。

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

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

serverControl.shutdown();

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

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