将数据库连接到HSQLDB服务器 [英] Connect databases to HSQLDB Server

查看:94
本文介绍了将数据库连接到HSQLDB服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以独立方式使用版本hsqldb-1.8.我想用一些数据库启动服务器.我想使用HSQLDB文档中的命令行:

I'm using version hsqldb-1.8 in a stand-alone way. I want to start the server with some databases. I'd like to use the command line from the HSQLDB documentation :

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

我的问题是我拥有所需的每个数据库的脚本,并且此命令行在不使用脚本的情况下创建了一个新数据库.可能问题出自以下几点之一:

My problem is I have the script of each database I need and this command line creates a new database, without using my script. May the problem comes from one of these points :

  • 我的脚本的位置
  • 脚本的扩展名是SQL文件
  • 命令行错误或丢失
  • 命令行无法执行此操作=>如果是,是否有任何方法可以执行此操作?

我想留在控制台中做所有的事情.这样,我只需启动脚本即可完成所有工作.任何帮助都感激不尽 !谢谢

I'd like to stay in the console to do all that. That way, I'll only have to launch a script to do all the job. Any help will be much appreciated ! Thanks

推荐答案

我找到了解决问题的方法:)

I found the solution of my issue :)

我已经在目录../hsqldb-1.8.10/hsqldb/中创建了一个server.properties文件,其中包含该文件:

I've created a server.properties file located in the directory ../hsqldb-1.8.10/hsqldb/ which contains that :

server.database.0=file:mydb;user=test;password=test
server.dbname.0=mydb

我还用以下代码创建了mydb.script文件:

I've also created the mydb.script file with that code in it:

CREATE SCHEMA PUBLIC AUTHORIZATION DBA
CREATE MEMORY TABLE MYDB(ID BIGINT NOT NULL,VERSION INTEGER NOT NULL,NOM VARCHAR(255))
CREATE USER TEST PASSWORD "TEST"
GRANT DBA TO TEST
SET WRITE_DELAY 10
SET SCHEMA PUBLIC
INSERT INTO MYDB VALUES(1,0,'test')

然后,我使用以下命令启动HSQLDB服务器:

Then, I launch the HSQLDB Server with this command:

java -cp ../lib/hsqldb.jar org.hsqldb.Server

我们可以看到数据库已成功创建:

We can see that the database is successfully created :

[Server@10f0f6ac]: Database [index=0, id=0, db=file:mydb, alias=mydb] opened successfully in 313 ms.

要检查数据库是否确实包含我的数据,请通过以下命令使用HSQLDB DatabaseManager工具:

To check if the database really contains my data, I use the HSQLDB DatabaseManager tool with this command:

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

要连接:

  • URL:jdbc:hsqldb:file:mydb
  • 用户:测试
  • 密码:测试

之后,我们连接到数据库.执行命令SELECT * FROM MYDB;,我们可以看到数据库行.

After that, we are connected to the database. Execute the command SELECT * FROM MYDB; and we can see the line of the database.

希望有帮助! :)

这篇关于将数据库连接到HSQLDB服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆