db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryan Pendleton <bpendleton.de...@gmail.com>
Subject Re: Embedded - can it be multi-user?
Date Sun, 03 Jul 2011 14:50:40 GMT
> Now, I was using the SQuirreL SQL Client to look at my databases
> as they were being created, but I couldn't use ij with the database
> *_and_* SQuirreL at the same time.

Correct. Two separate JVMs cannot both access the same database using
the embedded driver concurrently.

> What I'm wondering is, if there's a single app connecting to the database
> multiple times, is it up to the app to manage the connections so that
> only one connection is active at any one time, or how exactly does that
> work? Say in a context where an App Server is connecting to an embedded
> Derby database - i.e. no server running - does the App Server have to manage
> requests to the database in a queue or how, exactly does the system work?

Java is multi-threaded, and Derby's JDBC apis (the java.sql.* interfaces)
are thread safe. Multiple connections can be opened and used concurrently.

So a well-written application which processes work on behalf of multiple
users can certainly open multiple separate connections to the database,
and each connection (in a separate thread) can be performing
work concurrently using the same embedded driver, so long as this is all
a single JVM. (More precisely, it must be a single class-loader in a single
JVM; separate class loaders behave like separate JVMs w.r.t embedded use.)

Derby's NetworkServer is an example of such a well-written application, but
it is not the only one possible. Still, many people find it convenient
to use Derby's NetworkServer rather than writing their own. The
NetworkServer even has some simple support for being managed by an
application server: http://db.apache.org/derby/docs/10.8/adminguide/cadminservlet98430.html



View raw message