2009/05/20 - Apache Shale has been retired.

For more information, please explore the Attic.

Coverage Report - org.apache.shale.examples.sqlbrowser.InternalDataSource
 
Classes in this File Line Coverage Branch Coverage Complexity
InternalDataSource
0%
0/15
0%
0/1
2.5
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to you under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  *
 17  
  * $Id: InternalDataSource.java 464373 2006-10-16 04:21:54Z rahul $
 18  
  */
 19  
 
 20  
 package org.apache.shale.examples.sqlbrowser;
 21  
 
 22  
 import java.sql.Connection;
 23  
 import java.sql.SQLException;
 24  
 import org.apache.derby.jdbc.EmbeddedDataSource;
 25  
 
 26  
 /**
 27  
  * <p>Trivial implementation of <code>DataSource</code> that wraps a data source
 28  
  * provided by Derby, and provides a shutdown hook.</p>
 29  
  */
 30  
 public class InternalDataSource extends EmbeddedDataSource {
 31  
 
 32  
 
 33  
     // ------------------------------------------------------------ Constructors
 34  
 
 35  
 
 36  
     /**
 37  
      * <p>Construct a connection pool for the specified URL.</p>
 38  
      */
 39  0
     public InternalDataSource(String url) throws SQLException {
 40  
 
 41  
         // Instantiate and configure a Derby EmbeddedDataSource
 42  0
         setDatabaseName(url);
 43  0
         setCreateDatabase("create");
 44  
 
 45  0
     }
 46  
 
 47  
 
 48  
     // ---------------------------------------------------------- Public Methods
 49  
 
 50  
 
 51  
     /**
 52  
      * <p>Cause the embedded Derby database to be shut down.</p>
 53  
      */
 54  
     public void shutdown() throws SQLException {
 55  
 
 56  0
         setShutdownDatabase("shutdown");
 57  0
         Connection conn = null;
 58  
         try {
 59  0
             conn = getConnection();
 60  0
         } catch (SQLException e) {
 61  
             ; // Ignore errors here; we just wanted to trigger the shutdown
 62  
         } finally {
 63  0
             try {
 64  0
                 if (conn != null) {
 65  0
                     conn.close();
 66  
                 }
 67  0
             } catch (SQLException e) {
 68  
                 ;
 69  0
             }
 70  0
         }
 71  
 
 72  0
     }
 73  
 
 74  
 
 75  
 }