27.8.09

Embedded DB within Java using Derby/JavaDB

Reference: http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javadb/

1. Download JavaDB from
http://developers.sun.com/prodtech/javadb/downloads/
or Apache Derby site.

2. Copy derby.jar to your runtime environment

3. Create a JDBC connection to an embedded Derby DB using code similar to the following:
String dbName = "testDb";
Properties props = new Properties();
props.put("user", "testuser");
props.put("password", "testpass");

conn = DriverManager.getConnection("jdbc:derby:" + dbName
+ ";create=true", props);

Note that within Java 6/JDBC 4, you don't need to call Class.forName() explicitly to load the JDBC driver.

4. Nothing else. Enjoy it!

No comments: