private EmbeddedConnectionPoolDataSource createDataSource(final String databaseName) {
   final EmbeddedConnectionPoolDataSource embeddedConnectionPoolDataSource =
       new EmbeddedConnectionPoolDataSource();
   embeddedConnectionPoolDataSource.setDatabaseName(databaseName);
   embeddedConnectionPoolDataSource.setCreateDatabase("create");
   return embeddedConnectionPoolDataSource;
 }
 @Override
 protected EmbeddedConnectionPoolDataSource createDataSource() {
   if (!loadDbDriver("org.apache.derby.jdbc.EmbeddedDriver")) {
     throw new RuntimeException("Unable to loadDB driver:  org.apache.derby.jdbc.EmbeddedDriver");
   }
   EmbeddedConnectionPoolDataSource dataSource = new EmbeddedConnectionPoolDataSource();
   dataSource.setDatabaseName(dbDir.getAbsolutePath());
   dataSource.setCreateDatabase("create");
   System.err.println("Created derby cache");
   return dataSource;
 }
예제 #3
0
  static {
    PR = new PropertiesManager(PROPERTIES_FILE_PATH);
    DATABASE_NAME = getDataBaseName();

    try {
      Class.forName(DRIVER).newInstance();
    } catch (ReflectiveOperationException e) {
      throw new RuntimeException(e);
    }

    DS = new EmbeddedConnectionPoolDataSource();
    DS.setDatabaseName(DATABASE_NAME);
    DS.setCreateDatabase("create");
  }
예제 #4
0
 /**
  * Devuelve una conexión desde el pool de conexiones con el usuario y la contraseña especificados
  *
  * @param user
  * @param pass
  * @return
  * @throws SQLException
  */
 public static Connection getConnection(String user, String pass) throws SQLException {
   return DS.getConnection(user, pass);
 }
예제 #5
0
 /**
  * Devuelve una conexión desde el pool de conexiones sin usuario ni contraseña (suficiente
  * normalmente)
  *
  * @return
  * @throws SQLException
  */
 public static Connection getConnection() throws SQLException {
   return DS.getConnection();
 }