0

i am starting hsqldb server with db_name as MDB and credentials as user=test and password=test using command prompt as:

    java -cp hsqldb.jar org.hsqldb.server.Server --database.0 file:/E:/DB/mdb --dbname.0 mdb user=test 
    password=test

it starts the server without error but when i use same credentials in my java code as

    con = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/mware;file:E:/DB/mdb", "test", 
    "test");

it throws exception as:

 {java.sql.SQLInvalidAuthorizationSpecException: invalid authorization specification - not found: test
    at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
    at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
    at org.hsqldb.jdbc.JDBCConnection.<init>(Unknown Source)
    at org.hsqldb.jdbc.JDBCDriver.getConnection(Unknown Source)
    at org.hsqldb.jdbc.JDBCDriver.connect(Unknown Source)}

please help

Maha Saad
  • 115
  • 10

1 Answers1

0

The correct way to start the server is:

java -cp hsqldb.jar org.hsqldb.server.Server --database.0 file:/E:/DB/mdb;user=test;password=test --dbname.0 mware 

And the connection should be like this:

con = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/mware, "test", 
"test");

Any initial database settings in addition to user and password is defined the same way. For example --database.0 file:/E:/DB/mdb;user=test;password=test;hsqldb.tx=mvcc. The properties are applied to a new database and can be changed later with SQL statements. See http://hsqldb.org/doc/2.0/guide/dbproperties-chapt.html#dpc_db_operations

fredt
  • 24,044
  • 3
  • 40
  • 61
  • Thanks @fredt, its a nice way to go. I also tried it using your another post comment, using java code as p.setProperty("server.database.2", "file:G:/db1/mware;user=test;password=test"); p.setProperty("server.dbname.2", "mware"); server.start(); and then Class.forName("org.hsqldb.jdbc.JDBCDriver"); and mentioned the connection url – Maha Saad Nov 05 '20 at 06:40
  • Can you kindly tell me: Is there any way to mention "multithreading enabled" in In-Process:file mode database, or it is enabled by default in any encrypted in-proc:file type db.Following is my db url: getConnection("jdbc:hsqldb:file:C:\\inprocess\\mware;crypt_key=xxxxxxxxxxxxxxx;crypt_type=AES;crypt_lobs=false" – Maha Saad Nov 05 '20 at 06:44
  • I have found this property hsqldb.tx=MVCC but will it help me in my multithreaded application performing diff operations on same/as well diff tables? – Maha Saad Nov 05 '20 at 07:54
  • The MVCC mode is useful when there are a lot of writes at the same time as reads. If you are mostly reading from the tables, the default `locks` mode should be OK, Read the Guide. – fredt Nov 06 '20 at 14:22
  • (On time slot 1) My service is receiving data from multiple clients and I am writing in inprocess hsqldb also. While on another time(Time slot 2), I am reading the data from in-process db and getting the data to be written from another bunch of clients at the same time. So Should i use mvcc or locks? – Maha Saad Nov 17 '20 at 06:26
  • If the duration of SQL INSERT and UPDATE statements is short, it doesn't matter. Otherwise MVCC is better. – fredt Nov 17 '20 at 12:58