问题
I'm searching a good (JDBC-compatible) replacement for SQLite in java. I've found hsqldb and it's quite satisfying me, but there are some questions.
First. How it operates when database size will be 3-4GB? Still load all to RAM?
Second. There said, it can support binary format, not only script. How can I enable it?
Class.forName("org.hsqldb.jdbcDriver");
PleaseHsqlUseBinaryFormat(); // What should I write here or somewhere else?
link = DriverManager.getConnection("jdbc:hsqldb:file:/tmp/mydatabase.hsql","sa","");
try
{
// Work with database
}
回答1:
HSQLDB is flexible and allows you to choose how the data is stored. If you want the data to be stored in disk tables, use CACHED tables. The easiest way to do this is by adding a property to the connection URL:
jdbc:hsqldb:file:/tmp/mydatabase.hsql;hsqldb.default_table_type=cached
All CREATE TABLE and similar statements are stored in the .script file. If you don't want this file to be in text format, add another property:
jdbc:hsqldb:file:/tmp/mydatabase.hsql;hsqldb.default_table_type=cached;hsqldb.script_format=3
The Guide covers the different options:
http://hsqldb.org/doc/2.0/guide/management-chapt.html
来源:https://stackoverflow.com/questions/13432262/how-to-write-hsqldb-in-binary-form