Wednesday, August 29, 2007

Java DB: It's both embedded *and* a server

Some emails I have been reading indicate that not everyone knows there is this cool feature in Java DB/Derby. With a simple call in Java or by setting a property, you can have a VM with an embedded Derby database that also allows other processes to connect to and use this database through the network JDBC driver.

The instructions on how to enable the network server are here.

You either set the property derby.drda.startNetworkServer=true in your derby.properties file or you can start it explicitly:

NetworkServerControl server = new NetworkServerControl();
server.start (null);

Pretty darn simple...

1 comment:

Anonymous said...

Thanks a lot for this hint.
One additional info:
The org.apache.derby.jdbc.ClientDriver jdbc driver expects the user id and the password to be at least one character long.
If you have no user/password constraints set on your db started in embedded mode, it doesn't matter what user and password you provide, as long as they are at least one character long.