日期:2014-05-16  浏览次数:20324 次

hsqldb常识

?

The HSQLDB jar package is located in the /lib directory of the ZIP package and contains several components and?programs.

?

? HyperSQL RDBMS Engine (HSQLDB)

? HyperSQL JDBC Driver

? Database Manager (GUI database access tool, with Swing and AWT versions)

? Sql Tool (command line database access tool)

?

Running Database Access Tools

?

java -cp ../lib/hsqldb.jar org.hsqldb.util.DatabaseManagerSwing

?

?

When a tool is up and running, you can connect to a database (may be a new database) and use SQL commands to?access and modify the data.

?

?

A HyperSQL Database

?

Types of catalog data

? mem: stored entirely in RAM - without any persistence beyond the JVM process's life

? file: stored in filesystem files

? res: stored in a Java resource, such as a Jar and always read-only

?

?

?

?

In-Process Access to Database Catalogs

file:

?

Connection c = DriverManager.getConnection("jdbc:hsqldb:file:testdb", "SA", "");

?或者

?

Connection c = DriverManager.getConnection("jdbc:hsqldb:file:/opt/db/testdb", "SA", "");
?

mem:

?

Connection c = DriverManager.getConnection("jdbc:hsqldb:mem:mymemdb", "SA", "");

?res:

?

Connection c = DriverManager.getConnection("jdbc:hsqldb:res:org.my.path.resdb", "SA", "");
?

?

The first time in-process connection is made to a database, some general data structures are initialised and a few helper?threads are started. After this, creation of connections and calls to JDBC methods of the connections execute as if they?are part of the Java application that is making the calls. When the SQL command "SHUTDOWN" is executed, the?global structures and helper threads for the database are destroyed.

?

?

Note that only one Java process at a time can make in-process connections to a given file: database. However, if the?file: database has been made read-only, or if connections are made to a res: database, then it is possible to make inprocess?connections from multiple Java processes.

?

HyperSQL HSQL Server

?

java -cp ../lib/hsqldb.jar org.hsqldb.server.Server --database.0 file:mydb --dbname.0 xdb
?

HyperSQL HTTP Server

?

This method of access is used when the computer hosting the database server is restricted to the HTTP protocol. The?only reason for using this method of access is restrictions imposed by firewalls on the client or server machines and it?should not be used where there are no such restrictions. The HyperSQL HTTP Server is a special web server that allows?JDBC clients to connect via HTTP. The server can also act as a small general-purpose web server for static pages.

?

?

org.hsqldb.server.WebServer
?

HyperSQL HTTP Servlet

?

The Servlet class, in the HSQLDB jar, should be installed on the application server to provide the

connection. The database is specified using an application server property. Refer to the source file src/org/hsqldb/server/Servlet.java to see the details.

?

?

Both HTTP Server and Servlet modes can only be accessed using the JDB