数据未保存在HSQL的MEMORY表中 [英] Data is not saving in MEMORY table of HSQL
问题描述
我已经在HSQL中创建了一个MEMORY表.但是数据只能在我的Java应用程序运行时保存和访问.在HSql FAQ中,他们说,
I have created a MEMORY table in HSQL. But the data is saved and accessed only in the running of my Java application.In HSql FAQ they said that,
...the default, MEMORY tables are persistent.
程序存在后,数据不是持久性的.这是什么问题?
The data is not persistent after the program exists. What is the problem here?
SQL:
CREATE MEMORY TABLE SESSIONS(
SESSION_DATE DATE NOT NULL,
IN_TIME TIMESTAMP NOT NULL,
OUT_TIME TIMESTAMP NOT NULL)
Java:
DriverManager.getConnection("jdbc:hsqldb:file:"+
DbConnection.class.getResource("/loginTimerDB").getPath()+"/loginTimerDB",
"SA",
"");
我已将此数据库文件放置在java包中,以在部署时制作一个简单的jar文件.
好的.起初,我对在jar文件中打包数据库有相同的想法.所以我已经将hsql数据库文件夹移到了源包的外面.而且,我更改了如下的Java代码,
Ok. at first I have the same thought about packing database in jar file. so I have moved that hsql database folder, to out side of the source packages. And, I have changed the java code like below,
"jdbc:hsqldb:file:loginTimerDB/loginTimerDB"
我以前使用过hsql db,但从未遇到过这样的问题.
I have previously worked with hsql db, and never had a problem like this.
推荐答案
您是否在应用程序退出之前关闭数据库?关于 Hsqldb用户指南,关闭数据库,您必须发送SHUTDOWN
通过JDBC连接的命令
Are you closing the database before your application exits? Regarding to the Hsqldb User Guide, Closing the Database, you have to send a SHUTDOWN
command via the JDBC connection
connection.prepareStatement("SHUTDOWN").execute();
或在连接字符串中设置shutdown=true
属性:
or set the shutdown=true
property in the connection string:
jdbc:hsqldb:file:loginTimerDB/loginTimerDB;shutdown=true
这篇关于数据未保存在HSQL的MEMORY表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!