db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel John Debrunner <...@apache.org>
Subject Re: Using Apache DBCP and Tomcat with Derby - database shutdown?
Date Thu, 07 Sep 2006 22:31:07 GMT
home4slc@pacbell.net wrote:

> Hi Deepa,
>  
> Thanks a lot for your help.  That worked like a charm.
>  
> So I have now changed my code to this:
>  
>    ((EmbeddedDataSource)ds).setShutdownDatabase("shutdown");
>    ((EmbeddedDataSource)ds).getConnection();

Just a couple of warnings with this code:

   1) This affects the datasource for every application or thread that
is using it.
   2) Some J2EE app servers will wrap the database's DataSource
implementation in their own, meaning the cases will fail.

Another way is to have another Derby data source setup in the
configuration that has the shutdownDatabase property set to "shutdown".
Then you would do:

Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource)
  envCtx.lookup("jdbc/EmployeeDB_shutdown");

try {
  ds.getConnection();
} catch (SQLExcepion sqle) {
}

Dan.



Mime
View raw message