public long getChannelSize()

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


  public long getChannelSize(Connection connection) {
    long size = 0L;
    Statement stmt = null;
    try {
      stmt = connection.createStatement();
      stmt.execute(QUERY_CHANNEL_SIZE);
      ResultSet rset = stmt.getResultSet();
      if (!rset.next()) {
        throw new JdbcChannelException("Failed to determine channel size: "
              + "Query (" + QUERY_CHANNEL_SIZE
              + ") did not produce any results");
      }

      size = rset.getLong(1);
      connection.commit();
    } catch (SQLException ex) {
      try {
        connection.rollback();
      } catch (SQLException ex2) {
        LOGGER.error("Unable to rollback transaction", ex2);
      }
      throw new JdbcChannelException("Unable to run query: "
          + QUERY_CHANNEL_SIZE, ex);
    } finally {
      if (stmt != null) {
        try {
          stmt.close();
        } catch (SQLException ex) {
          LOGGER.error("Unable to close statement", ex);
        }
      }
    }

    return size;
  }