public boolean schemaExists()

in flume-jdbc-channel/src/main/java/org/apache/flume/channel/jdbc/impl/DerbySchemaHandler.java [368:409]


  public boolean schemaExists() {
    Connection connection = null;
    Statement stmt = null;
    try {
      connection = dataSource.getConnection();
      stmt = connection.createStatement();
      ResultSet  rset = stmt.executeQuery(QUREY_SYSCHEMA_FLUME);
      if (!rset.next()) {
        LOGGER.warn("Schema for FLUME does not exist");
        return false;
      }

      String flumeSchemaId = rset.getString(1);
      LOGGER.debug("Flume schema ID: " + flumeSchemaId);

      connection.commit();
    } catch (SQLException ex) {
      try {
        connection.rollback();
      } catch (SQLException ex2) {
        LOGGER.error("Unable to rollback transaction", ex2);
      }
      throw new JdbcChannelException("Unable to query schema", ex);
    } finally {
      if (stmt != null) {
        try {
          stmt.close();
        } catch (SQLException ex) {
          LOGGER.error("Unable to close schema lookup stmt", ex);
        }
      }
      if (connection != null) {
        try {
          connection.close();
        } catch (SQLException ex) {
          LOGGER.error("Unable to close connection", ex);
        }
      }
    }

    return true;
  }