Derby 服务器连接已存在
在我的应用程序中,我需要检查 Derby 服务器是否已在运行,如果没有则启动服务器。有人能告诉我如何检查吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
在我的应用程序中,我需要检查 Derby 服务器是否已在运行,如果没有则启动服务器。有人能告诉我如何检查吗?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
我能想到的最简单的方法是检索 Derby
Connection
。如果检索连接时抛出异常,则该连接很可能不存在,您可以启动一个。The simplest way I can think of is to retrieve a Derby
Connection
. If there's an exception thrown by retrieving the connection, chances are the connection doesn't exist and you can start one.通过 NetworkServerControl 类还可以使用“ping”命令: http://db.apache.org/derby/docs/10.8/publishedapi/jdbc4/org/apache/derby/drda/NetworkServerControl.html
There is also a 'ping' command available through the NetworkServerControl class: http://db.apache.org/derby/docs/10.8/publishedapi/jdbc4/org/apache/derby/drda/NetworkServerControl.html