CTRL + C
I am using hibernate and an HSQL database. Everything goes merrily along until I want to end the program. The only documentation I can find on starting up and shutting down the connection tells me to use CTRL + C (Windows command line); how can I send that command to Windows via Java?
It is an in-memory database, so if there is another solution, I am open to it. The database connection is established using the following line of code
Runtime.getRuntime().exec("java -classpath lib/hsqldb.jar org.hsqldb.Server");
Thanks
[547 byte] By [
83buttersa] at [2007-11-27 11:51:54]

It really shouldn't be your application's (the client of the database) job to start nor shutdown the database in the first place. That should be an external dependency, where the database is required to be up before you run the app, and the app doesn't try to start nor stop it.
So your design should change before you do anything about this.
This is an in-memory, HSQL database. There is no internet connection that occurs here. If the app does not control the database stopping and starting, what would you suggest? Every user who runs this app will have their very own database, and that needs to be controlled somehow. Are you suggesting some sort script that occurs at startup and shutdown?
Ok.
I happen to have used HSQL for an in-memory database before, and what I did was to use the Hypersonic sql tool to initialize the database. This tool is the org.hsqldb.util.SqlTool class, which you can use directly in your code like this for an example snippet:
String[] sqlToolArgs = { "--rcfile", sqlDir + "/yourFile.rc",
"test", sqlDir + "/yourFile.sql" };
System.setProperty("sqltool.noexit", "true");
SqlTool.main(sqlToolArgs);
Then when your app dies, so does the database as you didn't actually start up another VM instance (or so I believe - I believe the SqlTool.main method doesn't try to start up another VM).
It is by no means necessary to start it from outside of your applications, that is the whole point using an embeddable database like HSQLDB or Java DB.
Its just a matter of selecting the HSQLDB driver and connecting to it through jdbc with the right options, here is an example:
http://www.juixe.com/techknow/index.php/2007/04/09/embedding-hsqldb/
olaka at 2007-7-29 18:41:08 >

> It is an in-memory database, so if there is another
> solution, I am open to it. The database connection is
> established using the following line of code
>
> Runtime.getRuntime().exec("java -classpath
> lib/hsqldb.jar org.hsqldb.Server");
>
> Thanks
I don't get it. Yes, it can be configured to be used as an in memory database, but it looks like you aren't using it as an in memory database.
Kaj
kajbja at 2007-7-29 18:41:08 >
