Up to Derby 10.4.2.0, the in-memory database mode wasn’t a real one because data was stored into files onto your disk. The new 10.5.1.1 supports a real in-memory mode were data is only stored in memory, with no files being created. As stated in the new features page : Initial implementation of a storage engine for Derby where all data is kept in memory. There is no documentation for this feature. This functionality itself is not yet fully implemented, but users are welcome to experiment with it. So I did test it.
First of all, if you are using Maven, you will be disappointed to know that the 10.5.1.1 release is not in the default Apache repository. You need to add the following repository to your pom.xml :
<repository> <id>Apache Repo</id> <name>Apache repository for Derby 10.5.1.1</name> <url>http://people.apache.org/repo/m1-ibiblio-rsync-repository</url> <layout>legacy</layout> </repository>
Then, the JDBC URL has to be changed from jdbc:derby:chapter02DB;create=true to jdbc:derby:memory:chapter02DB;create=true.
As a little benchmark, I have an application with 25 test cases using in-memory storage with Derby 10.4.2.0. It took 5 minutes and 53 seconds to run all the tests. With the new 10.5.1.1 it only took 21 seconds. Not bad.
hsqldb in in-memory mode is pretty cool for development too. I use it even for my blog (persistence mode of course) running on fairly old low mem hardware. But derby has the out-of-the-box advantage since it is included in the JDK as JavaDB 😉