如何在网络服务器模式下启动derby并仍然获得嵌入式连接? [英] How do you start derby in network server mode and still get an embedded connection?

查看:468
本文介绍了如何在网络服务器模式下启动derby并仍然获得嵌入式连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道如何在网络服务器模式下启动derby并仍然可以获得嵌入式连接?

I just want to know how I can start derby in network server mode and still be able to get an embedded connection?

谢谢。

推荐答案

您需要在嵌入式​​服务器模式下启动Derby。如果您已经在嵌入模式下使用Derby,可以通过在类路径中提供必要的文件,然后在启动应用程序时指定一些命令行参数来启用它。

You need to launch Derby in "embedded server mode". If you are already using Derby in embedded mode, this can be enabled by providing the necessary files in your classpath, then specifying a handful of command line arguments when launching the application.

首先确保以下jar位于应用程序的运行时类路径中。

First make sure the following jars are in your application's runtime classpath.

     derby.jar derbynet.jar

然后将以下命令行选项添加到用于启动应用程序的Java命令中。如果缺少类文件,这些选项将无效。

Then add the following command line options to the Java command used to launch your application. If the class files are missing, these options will have no effect.

    -Dderby.drda.startNetworkServer=true 
    -Dderby.drda.portNumber=8011

我在Tomcat托管的servlet中运行Derby,所以我将这些选项添加到catalina.bat文件中。

I'm running Derby from within a servlet hosted by Tomcat, so I added these options to the catalina.bat file.

启动应用程序并检查打开的网络套接字列表。

Start up your application and check the list of open network sockets.

    netstat -an | find "8011"

您现在应该看到Derby正在侦听8011上的连接。它现在可以连接到数据库使用Derby的客户端驱动程序(derbyclient.jar)。 http://docs.oracle.com/javadb/10.3上的说明。 3.0 / adminguide / radminembeddedserverex.html 很好地涵盖了这一部分。

You should now see Derby listening for connections on 8011. Its now possible to connect to the database using Derby's client driver (derbyclient.jar). The instructions at http://docs.oracle.com/javadb/10.3.3.0/adminguide/radminembeddedserverex.html cover this part pretty well.

有人暗示可能不鼓励在这种模式下运行Derby。我不相信是这样的。您的应用程序将继续使用嵌入式驱动程序访问数据库,而现在允许使用客户端驱动程序访问其他软件。

It was hinted that running Derby in this mode may be discouraged. I don't believe that to be the case. Your application will continue to access the database using the embedded driver, while other software is now permitted access using the client driver.

这篇关于如何在网络服务器模式下启动derby并仍然获得嵌入式连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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