How to browse a derby memory database with Eclipse Datasource Explorer?

可紊 提交于 2019-12-05 06:15:08

Hi after some more research I got the solution.

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.

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");

}

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.

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

User and Password: your choice

Regards,

Alex

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!