Whoops, sorry about that last reply .. .sticky fingers. I was too hasty on my previous(previous) response. Although the below appears to work it does not. The reason being in my Tomcat server.xml I am trying to use the Apache DBCP Basic Data source. <Resource name="jdbc/derby" type="javax.sql.DataSource" auth="Container" description="Derby airlinesDB database"/> <!-- Resource parameters for the Derby database --> <ResourceParams name="jdbc/derby"> <parameter> <name>factory</name> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value> </parameter> ... When I try to shut down the database using the code below I get this exception: java.lang.ClassCastException: org.apache.commons.dbcp.BasicDataSource at org.apache.derby.demo.persistence.DerbyDatabase.shutdown(DerbyDatabase.java:85) at org.apache.derby.demo.persistence.DataFactory.contextDestroyed(DataFactory.java:132) I suppose I could change the factory parameter to org.apache.derby.jdbc.EmbeddedDataSource, but as I mentioned I wanted to use the DBCP BasicDataSourceFactory. Any other thoughts? Thanks, Susan
----- Original Message ---- From: [EMAIL PROTECTED] To: Derby Discussion <[email protected]> Sent: Thursday, September 7, 2006 2:56:02 PM Subject: Re: Using Apache DBCP and Tomcat with Derby - database shutdown? 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(); Thanks, Susan ----- Original Message ---- From: Deepa Remesh <[EMAIL PROTECTED]> To: Derby Discussion <[email protected]> Sent: Thursday, September 7, 2006 9:54:08 AM Subject: Re: Using Apache DBCP and Tomcat with Derby - database shutdown? On 9/7/06, Susan L. Cline <[EMAIL PROTECTED]> wrote: [snip] > > 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. > To shutdown using Derby DataSource object, you may set "ShutdownDatabase" property by calling setShutdownDatabase("shutdown") method of data source. After setting this property, a call to getConnection method of data source will shutdown the database. Hope this helps. This information is in http://db.apache.org/derby/docs/dev/devguide/cdevresman19524.html There is an example which shows use of "CreateDatabase" property. Use of "ShutdownDatabase" property is similar to this. I had recently reviewed this section of developer guide. As you are using Derby in J2EE environment, it would be nice if you can also provide any suggestions to improve this section of the documentation. Thanks, Deepa
