Exemplo n.º 1
0
  /**
   * Create a connection based on specific database connection context.
   *
   * @return Connection
   */
  protected Connection createConnection() {
    JdbcConnectionContext jdcc = (JdbcConnectionContext) getDatabaseConnectionContext();
    Connection connection = null;
    if (jdcc.useConnectionPool()) {
      connection = ConnectionUtil.createPooledConnection(jdcc);
    } else {
      connection = ConnectionUtil.createConnection(jdcc);
    }

    if (connection == null)
      throw new CreateConnectionFailureException(
          "JdbcConnection:createConnection() failure for " + getConnectionName() + ".");

    return connection;
  }
 private Statement jdbcStatement() {
   if (jdbcStatement == null) {
     try {
       jdbcStatement = jdbcConnectionContext.getJdbcConnection().createStatement();
     } catch (SQLException e) {
       throw new PersistenceException(
           "Unable to generate JDBC Statement object for schema generation");
     }
   }
   return jdbcStatement;
 }