Subject Re: [Firebird-Java] Multiple connections to embedded Firebird
Author Roman Rokytskyy
Hi Garrett,

> My understanding is that embedded Firebird does not support multiple
> concurrent connections.

It is wrong understanding. You cannot connect to the same database file from
multiple processes (i.e. JVMs), but within one JVM you can open as many
connections as you like. See release notes.

> However, I am able to open multiple connections via Jaybird. I'm a bit
> suspect of these and suspect there will be problems (deadlocks?, data
> corruption?) if I use them non-serially (i.e. from different threads).

Driver takes care of this on Windows (by doing nothing except syncronizing
on connection object, embedded server is thread-safe) and Linux
(synchronizes on static mutex, embedded server is not thread-safe, release
notes contain more information).

Deadlocks are possible, but this is always possible when you have concurrent
transactions and has nothing to do with embedded server.

Data corruption does not happen because of using connection from multiple
connections on Windows. And you cannot open the same database from multiple
processes (i.e. JVMs) since file is opened in exclusive mode.

On Linux you have to take care that only one processes (i.e. JVMs) accesses
the same database, since the database file is accessed in shared mode, and
if no lock manager is running (and I'm not sure if uses it)
you will corrupt the database. But as long as you stay in one JVM everything
is ok.

> Is this the case? If so, should Jaybird throw an exception when
> multiple connections to the same database file are opened?

No. Everything is ok.