11

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.

jonalv
  • 5,706
  • 9
  • 45
  • 64

5 Answers5

7

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.

fredt
  • 24,044
  • 3
  • 40
  • 61
4

java -jar /hsqldb-2.3.2/hsqldb/lib/sqltool.jar --inlineRc=url=jdbc:hsqldb:localhost:3333/runtime,user=sa Enter password for sa: as2dbadmin SqlTool v. 5337. JDBC Connection established to a HSQL Database Engine v. 2.3.2 database

  • 8
    It's good practice on Stack Overflow to add an explanation as to why your solution should work. For more information read [How To Ask](http://stackoverflow.com/help/how-to-answer). – Fabian Schultz Dec 28 '16 at 14:00
1

This error has been hunting me for the last 5 hours. Together with this stupid error: HSQL Driver not working?

If you want to run your hsqldb on your servlet with Apache Tomcat it is necessary that you CLOSE the runManagerSwing.bat. I know it sounds trivial but even if you create the desired database and you run Eclipse J22 Servlet with Tomcat afterwards, you will get a bunch of errors. So runManagerSwing.bat must be closed.

Community
  • 1
  • 1
Tower Jimmy
  • 567
  • 1
  • 4
  • 15
0

See my sqltool answer over on the question "How to see all the tables in an HSQLDB database". The critical piece is setting up your sqltool.rc correctly and putting it in the right location.

Community
  • 1
  • 1
Mister_Tom
  • 1,500
  • 1
  • 23
  • 36
0

You can also use the following statement for getting a connection from a files based store. this can be used if you are running the application from Windows.

connection = DriverManager.getConnection("jdbc:hsqldb:file:///c:/hsqldb/mydb", "SA", "");
IKavanagh
  • 6,089
  • 11
  • 42
  • 47
japkpc
  • 73
  • 7