使用Java Derby数据库服务器应用程序

问题描述:

我想创建使用Java Derby数据库服务器应用程序。到目前为止,我已经成功地创建连接到可以从我开始使用CMD德比命令服务器访问Derby数据库客户端的终端应用。我需要做一个Java应用程序当中,跑的时候,将启动Derby数据库服务器。到目前为止,所有我所遇到的是这样

I am trying to create a Derby database server application using Java. So far i have managed to create client end applications that connect to the derby database which can be accessed from the server I started using derby cmd commands. What i need to make is a java application which, when ran, will start the derby database server. So far all I have come across is this

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

    serverControl.start();

我每次运行此code没有任何反应。我是新来德比,我真的需要这出我的应用程序。请不要提的Apache Derby或Oracle德比单证,因为我已经通过他们走了,不明白。一个简单的precise解决方案将是非常美联社preciated!

Every time I run this code nothing happens. I am new to Derby and I really need to figure this out for my application. Please don't mention Apache Derby or Oracle derby documentations as i have gone through them and failed to understand. A simple precise solution will be highly appreciated!

P.S。我有derbynet.jar文件添加到我的项目。

P.S. I have added the derbynet.jar file to my project.

要开始从同一个VM(德比10.11.1.1)作为应用程序服务器德比:

To start derby server from same VM (derby 10.11.1.1) as your application:

下载bin软件包:的http://ftp.ps.pl/pub/apache//db/derby/db-derby-10.11.1.1/db-derby-10.11.1.1-bin.zip

精华,去到DB-德比10.11.1.1斌\\ lib中

extract, and go to db-derby-10.11.1.1-bin\lib

从lib中所有jar文件复制到lib文件夹在您的应用程序,添加到依赖性。

copy all jars from lib to your lib folder in your app, add to dependencies.

然后在你的应用程序执行此:

then in your app execute this:

  String[] args = {"start"};
  // for other port;
  //   String[] args = {"start","-p","1088"};

  org.apache.derby.drda.NetworkServerControl.main( args);

如果你想为启动单独的进程,然后,使用:

If you would like to start separate process then, use:

Runtime.getRuntime().exec(cmdarray)

其中 cmdarray 是你的可执行文件路径和参数,运行它。

where cmdarray is your path to executable and parameters to run it.