protected void assertEqualDatabases(Statement stat1,Statement stat2) throws SQLException {
  ResultSet rs=stat1.executeQuery("select value from information_schema.settings " + "where name='ANALYZE_AUTO'");
  int analyzeAuto=rs.next() ? rs.getInt(1) : 0;
  if (analyzeAuto > 0) {
    stat1.execute("analyze");
    stat2.execute("analyze");
  }
  ResultSet rs1=stat1.executeQuery("SCRIPT simple NOPASSWORDS");
  ResultSet rs2=stat2.executeQuery("SCRIPT simple NOPASSWORDS");
  ArrayList<String> list1=new ArrayList<String>();
  ArrayList<String> list2=new ArrayList<String>();
  while (rs1.next()) {
    String s1=rs1.getString(1);
    s1=removeRowCount(s1);
    if (!rs2.next()) {
      fail("expected: " + s1);
    }
    String s2=rs2.getString(1);
    s2=removeRowCount(s2);
    if (!s1.equals(s2)) {
      list1.add(s1);
      list2.add(s2);
    }
  }
  for (  String s : list1) {
    if (!list2.remove(s)) {
      fail("only found in first: " + s + " remaining: "+ list2);
    }
  }
  assertEquals("remaining: " + list2,0,list2.size());
  assertFalse(rs2.next());
}

protected void assertEqualDatabases ( Statement stat1 , Statement stat2 ) throws SQLException { ResultSet rs = stat1 . executeQuery ( "select value from information_schema.settings " + "where name='ANALYZE_AUTO'" ) ; int analyzeAuto = rs . next ( ) ? rs . getInt ( 1 ) : 0 ; if ( analyzeAuto > 0 ) { stat1 . execute ( "analyze" ) ; stat2 . execute ( "analyze" ) ; } ResultSet rs1 = stat1 . executeQuery ( "SCRIPT simple NOPASSWORDS" ) ; ResultSet rs2 = stat2 . executeQuery ( "SCRIPT simple NOPASSWORDS" ) ; ArrayList < String > list1 = new ArrayList < String > ( ) ; ArrayList < String > list2 = new ArrayList < String > ( ) ; while ( rs1 . next ( ) ) { String s1 = rs1 . getString ( 1 ) ; s1 = removeRowCount ( s1 ) ; if ( ! rs2 . next ( ) ) { fail ( "expected: " + s1 ) ; } String s2 = rs2 . getString ( 1 ) ; s2 = removeRowCount ( s2 ) ; if ( ! s1 . equals ( s2 ) ) { list1 . add ( s1 ) ; list2 . add ( s2 ) ; } } for ( String s : list1 ) { if ( ! list2 . remove ( s ) ) { fail ( "only found in first: " + s + " remaining: " + list2 ) ; } } assertEquals ( "remaining: " + list2 , 0 , list2 . size ( ) ) ; assertFalse ( rs2 . next ( ) ) ; }
check if two databases contain the same met data .
