db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Embretsen <John.Embret...@Sun.COM>
Subject Re: Closig connection vs shutting down derby
Date Mon, 10 Mar 2008 13:12:23 GMT
musky wrote:
> what about the case where derby is run as a network server?

Just to make sure you are not making any invalid assumptions here:

I think the DatabaseManager library Donald mentioned is the one described on the
wiki at http://wiki.apache.org/db-derby/DatabaseManager. This is *not* part of
Derby, and I cannot tell from the information on that page how or when the
library shuts down databases.

A Derby database will not be automatically shut down when closing all
connections to it (assuming you are not using any external libraries such as the
one mentioned above).

The database may, however, be automatically shut down if you shut down the
Network Server (I think this depends on how you do that, e.g. via the command
line vs. in a Java program), or if you shut down the entire Derby system
(connection URL "jdbc:derby:;shutdown=true").

Shutting down the database is not vital in order to preserve your data or
anything like that, but it is recommended for a number of reasons, including:

  - letting other apps/processes boot the database without risking running
into issues related to double-boooting (as Narayanan already mentioned)
  - if you don't shut down your database before exiting your application, Derby
will automatically run recovery operations upon the next boot, thus making the
startup slower.

Shutting down using a JDBC URL always results in an SQLException being thrown.

To see an example of how to handle that, see the SimpleApp demo inlcuded in the
latest Derby release, or at
http://svn.apache.org/viewvc/db/derby/code/trunk/java/demo/simple/SimpleApp.java?view=markup
(search for "shutdown")

regards,

-- 
John


> Donald McLean-3 wrote:
>> The DatabaseManager library which run Derby in embedded mode just closes
>> all
>> of the connections and the database shuts itself down when the last
>> connection is closed.
>>
>> Donald
>>
>> On Sun, Mar 9, 2008 at 9:16 PM, musky <muskvar@gmail.com> wrote:
>>
>>> I have a doubt:
>>>
>>> i an application after obtaining a connection to a database and after i
>>> perform all required transactions on the tables of the database do i need
>>> to
>>> shutdown the database or is it enough if i just close the connection.
>>>
>>> i tried shutting down the database but i get the
>>> nontransientconnectionexception sql state:08006




Mime
View raw message