Sudhanshu Gupta
Sudhanshu Gupta

Reputation: 2315

HSQLDB data storage as file in Spring Boot Application, unable to visualize

I am trying my hands on spring boot application. I planned to use HSQLDB for the database.

Purpose: Create User Table, Insert, Update, Delete data

I created User Entity, User dao, and saved user data in the user entity. Everything is working fine.

What I want is to see the data in the table as we can see it for MySQL.

I tried to use razorSQL, Dbeaver but I can't see tables.

application.properties

spring.jpa.hibernate.ddl-auto: update
spring.jpa.hibernate.dialect=org.hibernate.dialect.HSQLDialect
spring.jpa.database: HSQL
spring.jpa.show-sql: true
spring.hsql.console.enabled: true

spring.datasource.url=jdbc:hsqldb:file:data/mydb
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driverClassName=org.hsqldb.jdbcDriver

I can see the User table data in the browser:

User data

Files created in the data folder:

User data folder

I have googled a lot but nothing helps.

Questions:

  1. Can we see the data stored in HSQLDB(when running) as we can see for the MySQL in PHPMyAdmin?
  2. In which file data is stored, I have seen that in the script file it saves all the statements (insert, delete etc). Do we have a separate file to store the data?
  3. what is the use of tmp folder created?

Let me know if you need more details. I need to be clear on this. It has taken a lot of time still I am not satisfied

Upvotes: 1

Views: 2870

Answers (2)

Sudhanshu Gupta
Sudhanshu Gupta

Reputation: 2315

I am able to visualize the data of hsqldb with the help of hsqldb.jar

Assuming

Database folder named "data" is created which contains files with mydb.log, mydb.properties, mydb.script, mydb.tmp

Steps to visualize when using it as fileDb.

1. Download HSQLDB jar.

2. Extract in the folder where we have "data" folder(it contains database files) database files generated ("data" folder).

3. Now we are in the folder, where database folder is created. Run this command "java -cp hsqldb-2.4.1/hsqldb/lib/hsqldb.jar org.hsqldb.util.DatabaseManagerSwing" here "hsqldb-2.4.1" is the downloaded hsqldb folder. It will open up a UI.

4. In this UI, make a new connection, select type as "HSQL Database Engine Standalone" put URL as "jdbc:hsqldb:file:data/mydb" (here data is the folder and mydb is the DB name), give user and password as defined in application properties, then say ok. It should connect. (Maken sure the path to the file DB is relative to the folder from where we opened the UI)

Let me know in case anyone is getting errors

Upvotes: 3

fredt
fredt

Reputation: 24352

You can run HSQLDB as a Server and connect to it simultaneously from your Spring app and from a database utility such as dBeaver. The connection URL will look like jdbc:hsqldb:hsql://localhost/mydb. This is very similar to the way MySQL is used.

Detailed coverage is here: http://hsqldb.org/doc/guide/listeners-chapt.html but see the introduction to the Guide first. You can also consult various step-by-step HSQLDB tutorials on the web.

Upvotes: 0

Related Questions