db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Susan L. Cline" <home4...@pacbell.net>
Subject Using Apache DBCP and Tomcat with Derby - database shutdown?
Date Thu, 07 Sep 2006 16:24:19 GMT
Hi,

This is not strictly a Derby question, but I'm hoping someone else has used Apache DBCP
with Tomcat and Derby.  

According to the Tomcat 5.0 docs:

The default data source support in Tomcat is based on the DBCP connection pool from the Jakarta
Commons subproject.

and here is some sample code to obtain this JNDI data source:

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

Connection conn = ds.getConnection();
... use this connection to access the database ...
conn.close();

I'm using this code to obtain my connections to Derby, however the question I have is how
to
shutdown Derby correctly when I shut down my web application?

My class that implements the ServletContextListener interface calls this shutdown method of
my application class to shutdown Derby:

try {
	System.out.println("Derby database shutting down.");
	DriverManager.getConnection(SHUTDOWN_URL);
} catch (Exception except) {
	System.out.println(except.getMessage());
}

But this does not seem correct because I'm obtaining the connections to Derby via the datasource
and a pool, and here I am shutting the database down using the DriverManager class.  Is this
okay?

I can't find anything in the DBCP documentation to help me shutdown the database cleanly.

Does anyone have any suggestions on how to do this?

If I do not get a response from this mailing list, I'll try the Apache DBCP mailing list or
maybe
Tomcat as well, but I thought I'd check here first.

Thanks,

Susan

Mime
View raw message