Tags in my blog

13 April 2009

How to create JavaDB database embeded and client/server

Embeded Mode

Run locally:
java -jar derbyrun.jar ij;
ij> connect 'jdbc:derby:firstdb;create=true';


To connect from java:
String driver = "org.apache.derby.jdbc.EmbeddedDriver";
String dbName="jdbcDemoDB";
String connectionURL = "jdbc:derby:" + dbName + ";create=true";



Client/Server Mode

Start the server:
java -jar derbyrun.jar server start

Start the client:
java -jar derbyrun.jar ij
ij> connect 'jdbc:derby://localhost:1527/seconddb;create=true';


To connect from java:
String driver = "org.apache.derby.jdbc.ClientDriver";
...
String connectionURL = "jdbc:derby://localhost:1527/" + dbName + ";create=true";

No comments: