简体   繁体   English

HyperSQL Server 2.4.1在运行时创建新数据库

[英]HyperSQL Server 2.4.1 creating new database during runtime

I have quick question. 我有一个快速的问题。 Is it possible to add new database when HSQL Server is running? HSQL Server运行时是否可以添加新数据库?

Quick view: 快速浏览:

  • when HSQL Server is starting (by runServer.bat file) server.properties with databases configuration is loading, 当HSQL Server正在启动(通过runServer.bat文件)具有数据库配置的server.properties加载时,
  • during Server runtime I'd like to add new database (from eg Java application) without restart database server etc. 在服务器运行时,我想添加新数据库(例如从Java应用程序中),而无需重新启动数据库服务器等。
  • I try to add many properties to the Server (eg remote_open) but I always get: "[Thread[HSQLDB Connection @52859374,5,HSQLDB Connections @754ba872]]: database alias= does not exist" because it try to connect to expected database instead of creating it... 我尝试向服务器添加许多属性(例如remote_open),但是我总是得到:“ [[Thread [HSQLDB Connection @ 52859374,5,HSQLDB Connections @ 754ba872]]:数据库alias =不存在”,因为它尝试连接到预期的数据库数据库而不是创建数据库...

Is it possible? 可能吗?

There is easy for many database systems but for HSQL I cannot find anything... 许多数据库系统都很容易,但是对于HSQL我什么也找不到。

You need to start the server in a special remote_open mode which allows new databases to be opened. 您需要以特殊的remote_open模式启动服务器,该模式允许打开新数据库。 In addition, you need to specify the file path of the new database when you connect. 另外,在连接时,您需要指定新数据库的文件路径。 When the server is started, check the messages for remote-open . 启动服务器后,检查消息中的remote-open Then connect with a URL like this jdbc:hsqldb:hsql://localhost/testx;file:mytextxfile In the URL testx is the network id of the database and file:mytextxfile is the file path of the database files. 然后,使用这样的URL连接jdbc:hsqldb:hsql://localhost/testx;file:mytextxfile在URL中, testx是数据库的网络ID,而file:mytextxfile是数据库文件的文件路径。

Server messages when it starts: 服务器消息启动时:

[Server@4c5e176f]: Startup sequence initiated from main() method
[Server@4c5e176f]: Loaded properties from [C:\ft\hsqldb_w_1_8_0_n_work\server.properties]
[Server@4c5e176f]: [Thread[main,5,main]]: start() entered
[Server@4c5e176f]: [Thread[HSQLDB Server @4c5e176f,5,main]]: run() entered
[Server@4c5e176f]: Initiating startup sequence...
[Server@4c5e176f]: [Thread[HSQLDB Server @4c5e176f,5,main]]: server.maxdatabases=10
[Server@4c5e176f]: [Thread[HSQLDB Server @4c5e176f,5,main]]: server.remote_open=true
[Server@4c5e176f]: [Thread[HSQLDB Server @4c5e176f,5,main]]: server.tls=false
....

Server messages when connecting to new database: 连接到新数据库时的服务器消息:

[Server@4c5e176f]: [Thread[HSQLDB Connection @63db6942,5,HSQLDB Connections @4c5e176f]]: 2:Trying to connect user 'SA' to DB (testx;file:mytextxfile)
[Server@4c5e176f]: [Thread[HSQLDB Connection @63db6942,5,HSQLDB Connections @4c5e176f]]: 2:Connected user 'SA'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM