| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| DerbyXAPoolDataSource | 
 | 
 | 3.0;3 | 
| 1 |  /** | |
| 2 |   * Copyright 2010 The Kuali Foundation Licensed under the | |
| 3 |   * Educational Community License, Version 2.0 (the "License"); you may | |
| 4 |   * not use this file except in compliance with the License. You may | |
| 5 |   * obtain a copy of the License at | |
| 6 |   * | |
| 7 |   * http://www.osedu.org/licenses/ECL-2.0 | |
| 8 |   * | |
| 9 |   * Unless required by applicable law or agreed to in writing, | |
| 10 |   * software distributed under the License is distributed on an "AS IS" | |
| 11 |   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | |
| 12 |   * or implied. See the License for the specific language governing | |
| 13 |   * permissions and limitations under the License. | |
| 14 |   */ | |
| 15 | ||
| 16 |  package org.kuali.rice.student.core.database; | |
| 17 | ||
| 18 |  import java.sql.SQLException; | |
| 19 | ||
| 20 |  import org.kuali.rice.core.database.XAPoolDataSource; | |
| 21 | ||
| 22 |  /** | |
| 23 |   * This extends the rice XAPoolDataSource and checks to see if a connection is being | |
| 24 |   * made using derby client driver. If a client driver is used and a connection cannot | |
| 25 |   * be obtained, means a derby server has not been started. In such a case must switch | |
| 26 |   * to use the embedded driver instead. If derby is set to startup in server mode, the | |
| 27 |   * embedded db will be reachable via a network connection. | |
| 28 |   *  | |
| 29 |   * @author Kuali Student Team | |
| 30 |   * | |
| 31 |   */ | |
| 32 |  @SuppressWarnings("deprecation") | |
| 33 | 0 |  public class DerbyXAPoolDataSource extends XAPoolDataSource{ | 
| 34 | ||
| 35 | private static final long serialVersionUID = 1L; | |
| 36 | ||
| 37 | public void afterPropertiesSet() throws Exception { | |
| 38 | 0 |          super.afterPropertiesSet(); | 
| 39 |          //If client connection fails, use embedded driver | |
| 40 | 0 |          if ("org.apache.derby.jdbc.ClientDriver".equals(getDriverClassName())){ | 
| 41 |              try{ | |
| 42 | 0 |                  getConnection(); | 
| 43 | 0 |              } catch (SQLException e) { | 
| 44 | 0 |                  super.shutdown(true); | 
| 45 | 0 |                  setDriverClassName("org.apache.derby.jdbc.EmbeddedDriver");                 | 
| 46 | 0 |              } | 
| 47 | } | |
| 48 | 0 |      } | 
| 49 | ||
| 50 | } |