0
votes

I have created database using hsql and also added one table using UI interface of swingmanager in java and hsql.

Point 1:

I created data base using the following details

Type : HSQL Database Engine Standalone
Driver: org.hsqldb.jdbcDriver
URL: jdbc:hsqldb:file:mydb
UserName: SA
Password: SA

Point 2: Have insterted some data from UI of hsql.

Point 3: hsql Connection is working

Point 4: Trying to read data using java code but getting exception saying - user lacks privilege or object not found error

  1. Similar issue -https://sourceforge.net/p/hsqldb/mailman/message/28944633/
  2. Tried with providing capital "SA" in while connecting to DB and also in code
  3. As hsql is case sensitive, try query like- SELECT ID FROM DOMAIN or SELECT ID FROM "DOMAIN"
  4. GO to this path -C:\hsqldb-2.4.1\hsqldb\data check that you don't have multiple copies of these files: mydb.log, mydb.lck, mydb.properties, etc in your workspace
  5. Tried this query in single quotes 'SELECT ID FROM DOMAIN'
  6. This link has one more solution - HSQLDB user lacks privilege or object not found error when making select statements with where
  7. You can try with creating different table with unique name instead of domain

    Resultset rs=stmt.executequery("Select * from testdemo");

This line throwing exception saying -user lacks privilege or object not found error

Actual Result:

user lacks privilege or object not found error

Expected Result: It should read data from table

1

1 Answers

0
votes

One of the most common issues working with HSQLDB is the missing/wrong database alias name in the connection string. when you start the HSQLDB server with the following command,

@java -classpath ../lib/hsqldb.jar org.hsqldb.server.Server --database.0 file:sampledb --db

the required connection URL is jdbc:hsqldb:hsql://localhost/sdb. Make sure that your new table is in the PUBLIC schema coz by default that's where the driver would look for the table. From what you have told, if you are able to query the table using the UI tool, then this is more likely your connection string problem.

If you are using the file store run mode, you can connect from within the installation e.g. C:\servers\DB\hsqldb240\bin\runManagerSwing.bat (tro the swing UI manager) using the jdbc:hsqldb:file:testdb;ifexists=true; but to connect using java, you should specify the filedb location in the connection string like jdbc:hsqldb:file:C:\servers\DB\hsqldb240\testdb;ifexists=true;