Search code examples
hsqldbin-memory-database

Access to an embedded in-memory HSQLDB instance


My question relates to in-memory embedded HSQLDB. Say I have one database instance called my_db.

I assume the following code allows to access the above database instance:

org.hsqldb.util.DatabaseManagerSwing.main(new String[] { "--url", "jdbc:hsqldb:mem:my_db", "--noexit" });
  • Can I access the database from wherever I want provided it is in the same JVM process?
  • In which specific part of the memory is the data held?
  • More generally, what rules and restrictions determine from where and how I can access the database instance?

Solution

  • Q: Can I access the database from wherever I want provided it is in the same JVM process?

    A: Yes you can.

    Q: In which specific part of the memory is the data held?

    A: In the memory heap of the JVM process

    Q: More generally, what rules and restrictions determine from where and how I can access the database instance?

    A: The rule is only one JVM process can access a single embedded database. If you need access from more than one JVM, then you need to run an HSQLDB Server instance.