Jesse Barnum
Jesse Barnum

Reputation: 6816

HSQLDB caching too aggressively?

In my application, I need the ability to close all HSQL connections, delete the database files, and then open new connections that create a new database. I am using CACHED tables on disk.

What I am finding is that HSQL is remembering the contents of the old database - even though I've completed deleted those files from disk and established new connections! I've put breakpoints on the constructors for the org.hsqldb.jdbc.JDBCConnection class to verify that I'm getting new Connection objects (I am).

If I stop and start the process, then HSQL correctly 'forgets' the old database and starts fresh, but this is a server-side process that I can't stop and start easily.

The only solution I've found so far is to make some tweak to the path to the HSQL data files, so that it will not try to use the cached data from the last connection. I'm hoping that there is some method I can call in HSQL to clear out the cache, so that new connections will start with no data remembered from the old data.

Upvotes: 1

Views: 693

Answers (1)

fredt
fredt

Reputation: 24352

You should shutdown the database. This closes any connections that are left open and clears up the caches.

The SQL statement, SHUTDOWN is used.

You can delete the files after shutdown.

Upvotes: 1

Related Questions