The Derby database also known as Java DB is an open source Java database. It is part of the Apache project and it is distribute with Sun Java JDK 6.
In order to create a Connection or a DataSource Object to an embedded Derby database, we need to have the derby jar file in our Java classpath. Derby comes with JDK 6. If you don't have it you can download it from the derby web site or from sun site. On Ubuntu Linux you can download it using apt-ge:
apt-get install sun-java6-javadb
In the following Java examples the database files are at data/testdb, the user name and the password are empty and the driver is set to create the database if it is doesn't exist.
Creating a single connection to an embedded Derby database:
return DriverManager.getConnection("jdbc:derby:data/testdb;create=true", "", "");
Creating a DataSource Object to an embedded Derby database:
javax.sql.DataSource ds = new EmbeddedDataSource();