You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Daniel Morton <dj...@yahoo.com> on 2006/07/01 15:32:59 UTC
Derby Shutdown
Hello All...
I was just wondering, why does Derby throw an
SQLException when it shuts down, ie:
DriverManager.getConnection("jdbc:derby:;shutdown=true");
I always thought that exceptions were for exceptional
circumstances, but shutting down seems to be the
expected outcome from asking the database to shut
down. Am I missing something? It just seems odd to
me to have the above line of code in a try/catch block
with the catch block not really doing anything because
it is what I wanted to happen in the first place.
If anyonce could shed some light on this for me, I'd
appreciate it.
Daniel Morton
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Re: Derby Shutdown
Posted by "Jean T. Anderson" <jt...@bristowhill.com>.
Daniel Morton wrote:
> Hello All...
>
> I was just wondering, why does Derby throw an
> SQLException when it shuts down, ie:
>
> DriverManager.getConnection("jdbc:derby:;shutdown=true");
A clean shutdown always throws SQL exception XJ015. While disconcerting,
it's harmless. Here's the explanation from [1]:
> The issue is that standard JDBC getConnection() method calls (either
> DriverManager or DataSource) are used to push the shutdown request to
> Derby. A successful return from these methods would require a Connection
> object to be returned. It seemed strange to return a connection object
> to a database or system that was no longer active, what state would the
> Connection be in, closed? So the decision was made to throw an
> exception, which I think matches spirit of the JDBC spec. (Null as a
> return is not supported by the spec).
>
> The use of the standard JDBC mechanisms to push the shutdown request
> means that the request can be passed to Derby by any networked JDBC
> driver (e.g. DB2 universal driver, RmiJDBC, Weblogic's old Tengah
> driver) as well as embedded.
>
> Any alternate solutions are welcome!
I hope this helps.
regards,
-jean
[1]
http://mail-archives.apache.org/mod_mbox/db-derby-dev/200409.mbox/%3C414EFFD7.4060401@debrunners.com%3E
Re: Derby Shutdown
Posted by Kathey Marsden <km...@sbcglobal.net>.
Daniel Morton wrote:
>Hello All...
>
>I was just wondering, why does Derby throw an
>SQLException when it shuts down, ie:
>
>
>
Shutdown is implemented with attributes on the url with the
getConnection() method which can either
a) return a connection
or
b) throw an exception.
Obviously it can't return a connection in this case so it has to throw
an exception.
http://java.sun.com/j2se/1.5.0/docs/api/java/sql/DriverManager.html#getConnection(java.lang.String,%20java.lang.String,%20java.lang.String)
Not intuitive I agree, but the only way I guess to fit this
functionality into this API.
Kathey