SL5net
SL5net

Reputation: 2556

Querying a HSQLDB database on Ubuntu in Java

this code:

    c = DriverManager.getConnection("jdbc:hsqldb:file:company"); // jdbc:hsqldb:mem:company
    String query = "CREATE TABLE IF NOT EXISTS PUBLIC.USERS5 (name CHAR(25), age INTEGER NOT NULL);";
    stmt = c.createStatement();
    stmt.executeQuery(query);
    query = "INSERT INTO USERS5 (name, age) VALUES ('Erich Fried', 7)";
    rs = stmt.executeQuery(query);
    rs.close();

produce this error:

Exception in thread "main" java.sql.SQLSyntaxErrorException: 
user lacks privilege or object not found: USER

i changed the in config to Embedded

with path

/home/x/Downloads/sb/SpringBootApp/src

IDEA gives me then this URL:

jdbc:hsqldb:file:/home/x/Downloads/sb/SpringBootApp/src/company

and later this error:

Exception in thread "main" java.sql.SQLException: 
Database lock acquisition failure:
lockFile: org.hsqldb.persist.LockFile@4194dc76[
file=
/home/x/Downloads/sb/SpringBootApp/src/company.lck, exists=true, locked=false, valid=false, ] method: checkHeartbeat read: 2021-03-05 09:55:57 heartbeat - read: -8041 ms.

So i deleted:

/home/x/Downloads/sb/SpringBootApp/src/company.lck

now i get this error (complete error: https://gist.github.com/sl5net/062bd41e7d6beb5a608bff4a83d605bb ):

Exception in thread "main" java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: USER

In the meantime I tried the other connection types (all = Embedded, InMemory, UrlOnly) and got errors.

What else i could do?

Upvotes: 0

Views: 115

Answers (1)

fredt
fredt

Reputation: 24352

It seems from the stack trace that in your real SELECT statement you are referring to the table as USER instead of USERSS.

Regarding the `Database lock acquisition Failure": you have two Java processes accessing the same embedded file: database. The second process fails with this message.

Upvotes: 1

Related Questions