db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kristian Waagan <Kristian.Waa...@Sun.COM>
Subject Re: Shutdown cleanly embedded derby when tomcat shutdown ?
Date Mon, 14 Jul 2008 08:14:21 GMT
Albert Kam wrote:
> Dear all ..
> 
> Ah, finally, a solution that works !

[ snip ]

> 
> and use it in the source code like this :
>     public void shutdownDB() {
>         Context initCtx;
>         try {
>             log.debug("shutting down database from datasource");
>             initCtx = new InitialContext();
>             Context envCtx = (Context) initCtx.lookup("java:comp/env");
>             ds = (DataSource) envCtx.lookup("jdbc/SofcoSMSShutdown");
>             ds.getConnection();
>             ds = null;
>             log.debug("database shutdown complete");
>         } catch (NamingException e) {
>             log.error(e,e);
>             throw new InfrastructureException(e);
>         } catch (SQLException e) {
>             log.error(e,e);
>             throw new InfrastructureException(e);
>         }
>    }
> 

What does this piece of code log?
The getConnection-call is supposed to thrown an exception, also when the 
shutdown is successful. If successful, e.getSQLState() returns "08006".


-- 
Kristian

[ snip ]

Mime
View raw message