On 7/11/2012 10:14 PM, Matthew Hauck wrote:
>
> I am writing about the well known error: "Failed to start database
> '...' with class loader ..." I realize that you cannot have two
> simultaneous connections from two different JVMs to a derby embedded
> database. My question is whether or not it is possible to disconnect /
> "unload" / "unboot" one connection in order to load up the other one,
> etc. Or does the first JVM have to entirely stop before the next one
> can make a connection?
>
> I ask for TDD reasons. One of the tests I'm trying to write (on
> cucumber / jruby) requires some out-of-process testing. i.e. I have
> one process (cucumber) invoking the tests, which requires the spawning
> of another process. I would like the parent process to be able to turn
> off its connection to the embedded database (without shutting down),
> such that it can allow the spawned process to access the database, and
> then turn it back on and make sure things went as planned after the
> other process completes.
>
> Is this possible?
>
You can shutdown a single database without exiting the JVM using the
shudown=true attribute if using a DriverManager connection:
http://db.apache.org/derby/docs/10.9/ref/rrefattrib16471.html
or with the DataSource property shutdownDatabase()
http://db.apache.org/derby/docs/10.9/publishedapi/jdbc4/org/apache/derby/jdbc/EmbeddedDataSource40.html
This will allow another jvm to boot the database. Then then after the
spawned process completes, first jvm can reconnect which will reboot
the database.
Best
Kathey
|