Search code examples
database-connectionderby

Have additional connections to Derby (read-only)


What I want to do: My application has a full connection to a Derby DB, and I want to poke around in the DB (read-only) in parallel (using a different tool).

I'm not sure how Derby actually works internally, but I understand that I can have only 1 active connection to a Derby DB. However, since the DB is only consisting of files on my HDD, shouldn't I be able to open additional connections to it, in read-only mode?

Are there any tools to do just that?


Solution

  • There are two possibilities how to run Apache Derby DB.

    1. Embedded: You run DB within your application → only one connection possible
    2. Client: You start DB as server in separate process → classic DB with many connections

    You can recognize the type upon driver size. If the driver has more then 2MB that you use embedded version.

    Update

    When you startup the derby engine (server or embedded) it gets exclusive access to database files.

    If you need to access a single database from more than one Java Virtual Machine (JVM), you will need to put a server solution in place. You can allow applications from multiple JVMs that need to access that database to connect to the server.

    For details see Double-booting system behavior.