Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to connect to a file based HSQLDB database with sqltool?

Tags:

hsqldb

I have tried to follow the instructions in chapter 1 of the HSQLDB doc and started my server like:

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

and I have reason to believe that worked cause it said (among other things):

Database [index=0, id=0, db=file:#pathtodb#, alias=xdb] opened sucessfully in 2463 ms.

However at the next step I try to connect using SqlTool and based on chapter 8 of the documentation I came up with this command to connect:

java -jar hsqldb-2.2.5/hsqldb/lib/sqltool.jar localhost-sa

Which gives the following error:

Failed to get a connection to 'jdbc:hsqldb:hsql://localhost' as user "SA".
Cause: General error: database alias does not exist

while the server says:

 [Server@60072ffb]: [Thread[HSQLDB Connection @4ceafb71,5,HSQLDB Connections @60072ffb]]: database alias= does not exist

I am at a loss. Should I specify alias when connecting somehow? What alias would my database have then? The server did not say anything about that...

(also, yes I have copied the sqltool.rc file to my home folder.

like image 217
jonalv Avatar asked Sep 07 '11 14:09

jonalv


People also ask

Is HSQLDB a relational database?

HSQLDB (HyperSQL DataBase) is the leading SQL relational database system written in Java. It offers a small, fast multithreaded and transactional database engine with in-memory and disk-based tables and supports embedded and server modes.


1 Answers

Your server has -dbname.0 xdb as the database alias. Therefore the connection URL should include xdb. For example jdbc:hsqldb:hsql://localhost/xdb

The server can serve several databases with different aliases. The URL without alias corresponds to a server command line that does not include the alias setting.

like image 169
fredt Avatar answered Nov 02 '22 04:11

fredt