DineshM
DineshM

Reputation: 829

How to connect/query HSQL database outside application?

I am using embedded HSQL as a database for my Java application. And connecting to the database via Hibernate, below are the hibernate.cfg.xml file entries,

<property name="hibernate.connection.url">jdbc:hsqldb:file:testdb;shutdown=true</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>

I am able to connect to the database via my java application, hibernate is automatically creating tables, also inserting data into tables as i can see it in my application when i query tables via application.

But when i try to access my database via SQL Workbench, its not showing me any of the tables. It does get connected with below properties,

Driver - org.hsqldb.jdbcDriver  
URL - jdbc:hsqldb:file:testdb
UserName - sa
Password - 

After getting connected it shows below schemas,

*, INFORMATION_SCHEMA, PUBLIC, SYSTEM_LOBS

But when i fire select query for one of the tables it shows error as,

user lacks privilege or object not found: table_name [SQL State=42501, DB Errorcode=-5501]

So are there any specific configurations i need to do to connect my embedded database?

Upvotes: 0

Views: 912

Answers (1)

DineshM
DineshM

Reputation: 829

I was providing wrong information in URL, to connect to file based HSQL database you have to provide URL as below if you are on windows,

jdbc:hsqldb:file:C:\Softwares\eclipse-jee-mars-1-win32\eclipse\testdb

Need to mention full path of the database file. Its working fine for me now. Also for in-process file mode, only one connection can take place. Below link helped me to resolve the issue,
HSQL jdbcConnection class Documentation

Upvotes: 1

Related Questions