0
votes

I have following commands in Test.sql
create table MY_USER (id int,name varchar(10));
INSERT INTO MY_USER VALUES(1 ,'Test1');
INSERT INTO MY_USER VALUES(2 ,'Test2');

Java Code:-

Connection c = DriverManager.getConnection("jdbc:hsqldb:file:Test.sql, "sa", "");
Statement statement = c.createStatement();
statement.executeQuery("select * from MY_USER where name = 'Test1' ");
statement.execute("SHUTDOWN");
statement.close();

Issue: its giving me java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: MY_USER

1

1 Answers

0
votes

It doesn't work like this. You cannot include the Test.sql in your database URL.

First connect to a non-existent database, then use SqlTool (separate jar in HSQLDB distro) to execute the statements in Test.sql.

See the Guide:

http://hsqldb.org/doc/2.0/util-guide/index.html