找到你要的答案

Q:hsqldb *.script.new creating and deletion

Q:HSQLDB * script.new创建和删除。

I have a HSQLDB 1.8 in form of a mydata.properties and mydata.script. In mydata.script, there are some basic SQL statements to create the schema and populate the db.

When I use a standard Java JDBC call to load this database, I noticed that on the filesystem, the following seemingly happens:

  1. A file mydata.script.new is being created.
  2. The file mydata.script is deleted.
  3. mydata.script.new is renamed to mydata.script

How can I prevent mydata.script from being deleted? Is this normal HSQLDB behavior?

I would like mydata.script to persist (with its timestamp) at all times in the filesystem, it is meant as a read-only datasource.

EDIT: The manual does state that this is default behavior in Appendix C. In my use case, multiple programs (not only Java) read this db. If a program attempts reads to the .script file for the first time, just while it is being deleted because of first access of another program, it will cause errors.

EDIT2: If above is indeed not possible, is there not a way to transform this mydata.script (that contains all SQL calls) to some binary HSQLDB blob format that is just loaded through JDBC and not modified?

我有一个mydata.properties HSQLDB 1.8和mydata.script形式。在mydata.script,有一些基本的SQL语句来创建架构和填充数据库。

当我使用一个标准的java JDBC调用加载这个数据库,我注意到,在文件系统上的文件,下面的看似发生:

  1. A file mydata.script.new is being created.
  2. The file mydata.script is deleted.
  3. mydata.script.new is renamed to mydata.script

我怎样才能防止mydata.script被删除?这是正常的HSQLDB行为?

我想mydata.script坚持(其时间戳)在文件系统中所有的时间,这意味着作为一个只读数据源。

编辑:手工做的状态,这是我的使用情况在附录C中的默认行为,多个程序(不仅是java)读这分贝。如果一个程序试图第一次读取脚本文件,只是因为第一个程序被另一个程序删除,它会导致错误。

按2:如果上面确实是不可能的,没有办法改变这个mydata.script(包含所有SQL调用)一些二进制blob格式,只是加载HSQLDB通过JDBC和未改性的?

answer1: 回答1:

Based on your usage case, HSQLDB is probably not the right tool for the job.

It sounds like you want to access the database in-process from multiple applications, but HSQLDB does not support that. From the "Managing Database Connections" section of the Deployment Guide:

In all running modes (server or in-process) multiple connections to the database engine are supported. in-process (standalone) mode supports connections from the client in the same Java Virtual Machine,

So, if you want multiple concurrent connections from separate processes you should be using HSQLDB in "server" mode, but you likely don't want to be bothered with that.

Also, HSQLDB is tightly bound to Java so if you have non-Java applications that want access to the data you are probably making your life harder than it needs to be.

Another database format, possibly SQLite, might work better for you.

根据你的使用情况,HSQLDB可能不适合工作的工具。

这听起来像你想从多个应用程序访问数据库的过程,但HSQLDB不支持。从“管理数据库连接”部分的部署指南:

在所有运行模式(服务器或中间)到多个数据库引擎连接支持。在制品(独立)模式支持在同一个java虚拟机从客户端连接,

所以,如果你想从分开的过程,你应该使用“服务器”模式的HSQLDB的多个并发连接,但是你可能不想被打扰。

另外,HSQLDB紧密结合java所以如果你有非java应用程序想要访问你可能使你的生活更难比需要的数据。

另一个数据库SQLite格式,可能,可能更适合于你。

answer2: 回答2:

You can access a readonly HSQLDB database simultaneously from multiple processes. Add this line to the properties file to make the database readonly:

readonly=yes

你可以同时从多个进程访问一个只读HSQLDB数据库。这一行添加到文件的属性以使数据库只读:

readonly=yes
answer3: 回答3:

I found an answer to my question: There is a modified attribute that when set to no in a HSQLDB .properties file will prevent the behavior observed in my question.

我发现回答我的问题:有一个改进的属性,当设置为不在HSQLDB。属性文件将阻止我的问题行为观察。

java  sql  linux  jdbc  hsqldb