Hi, after some research, I got a solution.
To connect to the embedded derby database, you must run NetworkServerControl in your application. After that, you can connect to the derby database using, for example, Eclipse DTP Plugin / Datasource Explorer.
The code for creating db in memory and for running NSC might 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 must include derby.jar and derbynet.jar that come with jdk7 (lib \ db) in order to be able to create a NetworkServerControl and a database.
After that, you can connect to db while your application (and database) is running. Connection URL: jdbc: derby: // localhost: 1527 / memory: testdb
User and password: your choice
Hi,
Alex
source share