Is it necessary to have a Singleton ? Christian Bourque wrote: > > Hi, > > Here's my solution to do a clean shutdown of HSQL when using the file > version, I've used the experimental singleton feature of EJB 3.1 to do > that > but since it is only for testing I don't mind: > > ------------------------------------------------------------------------------------------------------------------- > @Singleton > @Startup > public class DatabaseBean implements Database > { > @Resource > private DataSource testDataSource; > > @PreDestroy > public void shutdown() > { > BasicManagedDataSource basicManagedDataSource = > (BasicManagedDataSource) testDataSource; > > if > (basicManagedDataSource.getJdbcDriver().equals("org.hsqldb.jdbcDriver")) > { > try > { > // this is a hack to do a clean shutdown of hsqldb... > > testDataSource.getConnection().createStatement().execute("SHUTDOWN"); > } > catch (Exception e) > { > e.printStackTrace(); > } > } > } > } > ------------------------------------------------------------------------------------------------------------------- > > Don't forget to change the the datasource name... > > Hope this helps! > > Christian > > On Fri, Oct 23, 2009 at 2:11 AM, hypnosat7 <abla...@yahoo.fr> wrote: > >> >> Hello, >> >> How can I close my hsql at the end of unit test, because my database is >> not closed at the end of the test: the entry 'modified' is set to 'yes' >> in >> the myHsqlDatabase.properties (http://hsqldb.org/doc/guide/apc.html) ? >> -- >> View this message in context: >> http://www.nabble.com/Closing-the-hsql-corrrectly-tp26021361p26021361.html >> Sent from the OpenEJB User mailing list archive at Nabble.com. >> >> > >
-- View this message in context: http://www.nabble.com/Closing-the-hsql-corrrectly-tp26021361p26036443.html Sent from the OpenEJB User mailing list archive at Nabble.com.