如何使用Eclipse Datasource Explorer浏览一个德比内存数据库? [英] How to browse a derby memory database with Eclipse Datasource Explorer?

查看:246
本文介绍了如何使用Eclipse Datasource Explorer浏览一个德比内存数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于单元测试,我使用的是一个德比内存数据库。

For unit testing I use a derby in-memory database.

有没有机会使用Eclipse Datasource Explorer等工具连接到这个数据库?运行?

Is there any chance to connect to this database using a tool like Eclipse Datasource Explorer when the test is running?

我google了很多,有时我发现了一些类似的东西:

I googled a lot and sometimes I found something like:

连接URL:jdbc:derby :// localhost:1527 / memory / mydb ...

Connection-URL: jdbc:derby://localhost:1527/memory/mydb...

但是对我来说没有用。

它表示1527是默认端口。

It says that 1527 is the default port.

是否可以使用像eclipse explorer这样的工具连接到derby内存数据库?
数据库是否打开连接端口?
或者有什么特别的,我必须配置这个工作?

Is it possible at all to connect to a derby memory database with a tool like eclipse explorer? Does the database open a connection-port to connect to? Or is there something special I have to configure for this to work?

谢谢,
亚历克斯

Thanks, Alex

推荐答案

经过一些更多的研究,我得到了解决方案。

Hi after some more research I got the solution.

要连接到嵌入式的德比内存数据库,你有在您的应用程序中启动NetworkServerControl。之后,您可以使用例如eclipse DTP Plugin / Datasource Explorer连接到derby数据库。

To connect to a embedded derby memory database you have to start the NetworkServerControl in your application. After that you are able to connect to the derby database by using for example the eclipse DTP Plugin / Datasource Explorer.

创建内存中db并启动的代码NSC可能如下所示:

The code to create the in-memory db and to start the NSC could look like this:

public static void main(String args[])
{
   NetworkServerControl nsc = new NetworkServerControl(InetAddress.getByName("localhost"), 1527);
   nsc.start(new PrintWriter(System.out, true));

   Class.forName("org.apache.derby.jdbc.EmbeddedDriver");

   Connection c = DriverManager.getConnection("jdbc:derby:memory:testdb;create=true");

}

你必须包括derby.jar&可以使用jdk7(lib\db)自带的derbynet.jar来创建NetworkServerControl和数据库。

You have to include the derby.jar & derbynet.jar that comes with the jdk7 (lib\db) to be able to create the NetworkServerControl and the database.

之后,您可以连接到db因为您的应用程序(和数据库)正在运行。
连接URL是:jdbc:derby:// localhost:1527 / memory:testdb

After that you can connect to the db as long as your application (and the database) is running. Connection-URL is: jdbc:derby://localhost:1527/memory:testdb

用户和密码:您的选择

问候,

Alex

这篇关于如何使用Eclipse Datasource Explorer浏览一个德比内存数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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