code: public static int getRowCount(Connection connection, String tableReference) throws SQLException {
          Statement st = connection.createStatement();
          int rowCount = 0;
          try {
              ResultSet rs = st.executeQuery(String.format("select count(*) rowcount from %s", TableLocation.parse(tableReference)));
              try {
                  if(rs.next()) {
                      rowCount = rs.getInt(1);
                  }
              } finally {
                  rs.close();
              }
          }finally {
              st.close();
          }
          return rowCount;
      }
docs: Fetch the row count of a table.
  @param connection Active connection.
  @param tableReference Table reference
  @return Row count
  @throws SQLException If the table does not exists, or sql request fail.