IanWatson
IanWatson

Reputation: 1739

HSQLDB Database multiple connections

Is it possible to connect to a HSQL database over multiple connections?

I have 2 connections using the same JDBC URL and the same hsqllib.jar and it appears I get a "new" database.

I imagine each connection is initializing the database in its memory?

Upvotes: 3

Views: 4798

Answers (1)

Ben Damer
Ben Damer

Reputation: 1036

You will need to run HSQLDB in standalone mode, and then connect both instances of your application to the standalone instance. The documentation describes how that start in server mode. For example, the following would start an in-memory database named database1:

java -cp ../lib/hsqldb.jar org.hsqldb.Server -database.0 mem:database1 -dbname.0 database1

You can then connect to that instance from your application using the following URL (assuming that everything is running on the same server):

jdbc:hsqldb:hsql://localhost/database1

Upvotes: 5

Related Questions