File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Why does Derby leave files on the hard drive? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Why does Derby leave files on the hard drive?" Watch "Why does Derby leave files on the hard drive?" New topic
Author

Why does Derby leave files on the hard drive?

Jeff Ballie
Greenhorn

Joined: Jul 02, 2007
Posts: 12
Hi,

I'm using Derby for some testing, and I thought it was a completely memory-resident database. However, I'm noticing some files are left behind on my hard drive. I'm not deliberately persisting anything to disk, and I haven't added anything to my code that seems to write to disk. Does anyone know what these files are? Or is Derby not entirely memory-resident?

Thanks!
Paul Campbell
Ranch Hand

Joined: Oct 06, 2007
Posts: 338
Jeff,

A memory resident database wouldn't be very useful since it would cease to exist when the machine failed, shutdown, restarted. You would lose all your data, stored procedures, etc. Derby stores each table and index, etc in a single file.

http://developers.sun.com/javadb/features/faqs.jsp#16
Jeff Ballie
Greenhorn

Joined: Jul 02, 2007
Posts: 12
Thanks for the link.

Looks like I misinterpreted what "memory-resident" means. In the derby case, it appears to mean that the entire contents of the database are loaded into memory - so the app doesn't need to read from disk at run time. I was under the impression it meant a database with a lifecycle similar to one of the container classes.

That said, I can actually see a use for a database that only exists as long as the application is running. Like using a linked list or hashmap for a specific purpose, then discarding it later without persisting it to disk.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42935
    
  68
If you're looking for a Java database that really leaves no trace of its data after it's shut down, have a look at HSQLDB. It has an in-memory mode that doesn't save the data.
Jeff Ballie
Greenhorn

Joined: Jul 02, 2007
Posts: 12
Thanks Ulf - I checked it out. This could work for me.

I'm a little bummed that Derby doesn't have a purely in-memory db, though, since this is the version that's going into Java 6. Does anyone know if this will still be the case for the version in Java (ie., no purely memory-resident DB)?

I suspect that a lot of model classes out there contain a large number of operations that are duplicating SQL at great expense. Personally, I'd get a lot of use out of an an in-memory database that would allow me to do various joins and sub-selects on data using SQL.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why does Derby leave files on the hard drive?