Hsqldb 简明教程
HSQLDB - Installation
HSQLDB 是用纯 Java 实现的关系数据库管理系统。您可以使用 JDBC 轻松地将此数据库嵌入应用程序中。或者,您可以单独使用该操作。
HSQLDB is a relational database management system implemented in pure Java. You can easily embed this database to your application using JDBC. Or you can use the operations separately.
Prerequisites
按照 HSQLDB 的先决软件安装指南进行操作。
Follow the prerequisite software installations for HSQLDB.
Verify Java Installation
由于 HSQLDB 是使用纯 Java 实现的关系型数据库管理系统,因此您必须在安装 HSQLDB 之前安装 JDK(Java Development Kit)软件。如果您已经在系统中安装了 JDK,请尝试以下命令来验证 Java 版本。
Since HSQLDB is a relational database management system implemented in pure Java, you must install JDK (Java Development Kit) software before installing HSQLDB. If you already have JDK installation in your system, then try the following command to verify the Java version.
java –version
如果 JDK 已成功安装在您的系统中,您将收到以下输出。
If JDK is successfully installed in your system, you will get the following output.
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
如果您尚未在系统中安装 JDK,请访问以下链接 Install JDK.
If you don’t have JDK installed in your system, then visit the following link to Install JDK.
HSQLDB Installation
以下是安装 HSQLDB 的步骤。
Following are the steps to install HSQLDB.
Step 1 − Download HSQLDB bundle
Step 1 − Download HSQLDB bundle
从以下链接下载 HSQLDB 数据库的最新版本 https://sourceforge.net/projects/hsqldb/files/. ,一旦您单击该链接,您将看到以下屏幕截图。
Download the latest version of HSQLDB database from the following link https://sourceforge.net/projects/hsqldb/files/. Once you click the link, you will get the following screenshot.
单击 HSQLDB,下载将立即开始。最后,您将获得名为 hsqldb-2.3.4.zip 的 zip 文件。
Click HSQLDB and the download will start immediately. Finally, you will get the zip file named hsqldb-2.3.4.zip.
Step 2 − Extract the HSQLDB zip file
Step 2 − Extract the HSQLDB zip file
解压缩 zip 文件并将其放入 C:\ 目录。解压缩后,您将获得如下屏幕截图所示的文件结构。
Extract the zip file and place it into the C:\ directory. After extraction, you will get a file structure as shown in the following screenshot.
Step 3 − Create a default database
Step 3 − Create a default database
HSQLDB 没有默认数据库,因此,您需要为 HSQLDB 创建一个数据库。让我们创建一个名为 server.properties 的属性文件,该文件定义了一个名为 demodb 的新数据库。查看以下数据库服务器属性。
There is no default database for HSQLDB, therefore, you need to create a database for HSQLDB. Let us create a properties file named server.properties which defines a new database named demodb. Take a look at the following database server properties.
server.database.0 = file:hsqldb/demodb
server.dbname.0 = testdb
将此 server.properties 文件放入 HSQLDB 主目录 C:\hsqldb- 2.3.4\hsqldb\ 中。
Place this server.properties file into HSQLDB home directory that is C:\hsqldb- 2.3.4\hsqldb\.
现在在命令提示符中执行以下命令。
Now execute the following command on command prompt.
\>cd C:\hsqldb-2.3.4\hsqldb
hsqldb>java -classpath lib/hsqldb.jar org.hsqldb.server.Server
执行上述命令后,您将收到服务器状态,如下面的屏幕截图所示。
After execution of the above command, you will receive the server status as shown in the following screenshot.
稍后,您会在 HSQLDB 主目录中找到 hsqldb 目录的以下文件夹结构,即 C:\hsqldb-2.3.4\hsqldb 。这些文件是 HSQLDB 数据库服务器创建的 temp 文件、lck 文件、日志文件、属性文件和 demodb 数据库的脚本文件。
Later, you will get to find the following folder structure of the hsqldb directory in the HSQLDB home directory that is C:\hsqldb-2.3.4\hsqldb. Those files are temp file, lck file, log file, properties file, and script file of demodb database created by HSQLDB database server.
Step 4 − Start the database server
Step 4 − Start the database server
创建数据库后,您必须使用以下命令启动数据库。
Once you are done creating a database, you have to start the database by using the following command.
\>cd C:\hsqldb-2.3.4\hsqldb
hsqldb>java -classpath lib/hsqldb.jar org.hsqldb.server.Server --database.0
file:hsqldb/demodb --dbname.0 testdb
执行上述命令后,您将获得以下状态。
After execution of the above command, you get the following status.
现在,您可以打开 runManagerSwing.bat 从 C:\hsqldb-2.3.4\hsqldb\bin 位置的数据库主页。此 bat 文件将打开 HSQLDB 数据库的 GUI 文件。在此之前,它将通过一个对话框询问您数据库设置。请看以下截图。在此对话框中输入设置名称,URL 如上所示,然后单击确定。
Now, you can open the database home screen that is runManagerSwing.bat from C:\hsqldb-2.3.4\hsqldb\bin location. This bat file will open the GUI file for HSQLDB database. Before that it will ask you for database settings through a dialog box. Take a look at the following screenshot. In this dialog box, enter the Setting Name, URL as shown above and click Ok.
您将获得如下截图所示的 HSQLDB 数据库的 GUI 界面。
You will get the GUI screen of HSQLDB database as shown in the following screenshot.