How to start a derby in network server mode and get a built-in connection?

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

Thanks.

+6
java derby
source share
5 answers

You need to run Derby in "embedded server" mode. If you are already using Derby in native mode, you can enable this by providing the necessary files in your class path, and then specifying a few command line arguments when starting the application.

First, make sure that the following banks are in your runtime execution path.

derby.jar derbynet.jar 

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

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

I run Derby from a servlet hosted by Tomcat, so I added these parameters to the catalina.bat file.

Launch the application and check the list of open network sockets.

  netstat -an | find "8011" 

Now you will see that Derby is listening on connections on 8011. Now it can be connected to the database using the Derby client driver (derbyclient.jar). The instructions at http://docs.oracle.com/javadb/10.3.3.0/adminguide/radminembeddedserverex.html very well reflect this part.

It was suggested that launching Derby in this mode might be discouraged. I do not think so. Your application will continue to access the database using the built-in driver, while other software is now allowed to access using the client driver.

+4
source share

Embedded server mode sounds like what you are asking for. It allows you to start the network server when starting the embedded database.

+2
source share

It sounds contradictory that you want to start the derby in network server mode and get the built-in driver. Even if this is possible, it is definitely not recommended. You must decide whether you want to use Apache Derby in network mode using DRDA or the built-in driver and stick to this solution.

Here you will find a guide for using the network driver: http://db.apache.org/derby/papers/DerbyTut/ns_intro.html

0
source share

Someone will correct me, if I am mistaken, both will work on separte ports. So you can connect to the right one using the correct connection name, right?

0
source share

@pawelocue: Sorry, but this is wrong. Using the embedded server mode is fine in order, and sometimes very useful. This is definitely not discouraging.

0
source share

All Articles