Hi Sebastien,

I'm also not a Spring expert - actually I never used it - but

+) you might be able to derive from org.apache.commons.dbcp.BasicDataSource and overwrite the close() method
+) add a custom HSQLDB shutdown bean for Spring
+) or write a little servlet which does the magic

Cheers,

Siegfried Goeschl

Sebastien Arbogast wrote:

from http://hsqldb.sourceforge.net/doc/guide/ch01.html#N10190

" All databases running in different modes can be closed with the
SHUTDOWN command, issued as an SQL query. In 1.7.2, in-process databases
are no longer closed when the last connection to the database is
explicitly closed via JDBC, a SHUTDOWN is required. When SHUTDOWN is
issued, all active transactions are rolled back. A special form of
closing the database is via the SHUTDOWN COMPACT command. This command
rewrites the .data file that contains the information stored in CACHED
tables and compacts it to size. This command should be issued
periodically, especially when lots of inserts, updates or deletes are
performed on the cached tables. Changes to the structure of the
database, such as dropping or modifying tables or indexes also create
large amounts of unused space that can be reclaimed using this command."

Having said that I'm not the HSQLDB expert - invoking stop() might solve
the problem but I prefer the SHUTDOWN since it compacts the database on
the fly.

I agree with you... the cleaner way to do things is to issue that damn
SQL SHUTDOWN but I don't know where I can configure something to issue
it automatically when my application is stopped. Does anyone know
where I can do this ?

Can't you just set reload="true" in your context.xml? That way when the
new war (or exploded war) is deployed, tomcat will reload the webapp
and there's no need to stop/start tomcat. Use only in dev-mode!

Oh yes it would be great. Anyway my application won't leave dev-mode
before a long time ;-). So I customized my context file to look like
this

<?xml version='1.0' encoding='utf-8'?>
<Context docBase="C:/dev/myapp/target/webapp" path="/myapp" reload="true">
</Context>

But then the problem is that when I recompile a few files, it happens
that as soon as the first file is being modified, a reload is
initiated while the other files haven't been recompiled yet, which
causes numerous exceptions since it breaks the integrity of my
application.

Where did you configure hsqldb to run? in server.xml or in the webapp?
If you configure it in server.xml there should be no locking problems..

HSQLDB is configured to run inside my webapp in In-process mode. So
it's configured thanks to this Spring bean configuration :

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
       <property
name="driverClassName"><value>org.hsqldb.jdbcDriver</value></property>
       <property name="username"><value>sa</value></property>
       <property
name="url"><value>jdbc:hsqldb:file:C:\dev\myapp/target/webapp/WEB-INF/db/myappdb</value></property>
   </bean>

So the file protocol allows me to avoid configuring any database
server. The database is a file accessed directly from within the main
application process. I know that this is not optimal in terms of
performance but I really don't care as my objective for now is to make
the deployment process as simple as possible since I'm still in dev
mode.

I think I really have to find a way to initiate a SHUTDOWN.


Reply via email to