title: How to compare resultsets of two different databases?
body: <p>I have two databases and i need to compare three rows from each database if they are matches, I have to print that row.</p>
  
  <p>Example:</p>
  
  <pre><code>Database 1:
  RuleId  Dataset  Partition  Date
  ------  -------  --------   ----
  1234     ABVD    012145    21/01/2014
  1256     ABCD    124565    22/01/2013
  4567     FGHJ    0123456  22/02/2013
  Database 2:
  1234    ABCD    012345    21/01/2014
  4567    FGHJ    0123456   22/02/2013
  7894    MNBV    0147896   20/01/2014
  </code></pre>
  
  <p>If RuleId,Dataset and Partition are equal in both databases I have to print those rows in output.</p>
  
  <p>My Code is as follows:</p>
  
  <pre><code>ArrayList&lt;String&gt; rslist = new ArrayList&lt;String&gt;();
  ArrayList&lt;String&gt; rs1list = new ArrayList&lt;String&gt;();
  int count = 1;
  while (rs.next()) {
      int i = 1;
      count = 1;
      while (i &lt; count) {
          rslist.add(rs.getString(i++));
      }
  
      rslist.add(rs.getString(2) + rs.getString(4) + (rs.getString(5)));
  
  }
  int count1 = 1;
  while (rs1.next()) {
      int i = 1;
      count1 = 1;
      while (i &lt; count1) {
          rs1list.add(rs1.getString(i++));
  
      }
      rs1list.add(rs1.getString("RuleId") + rs1.getString("Dataset")
              + rs1.getString("Partition"));
  }
  for (String s1 : rslist)
      for (String s2 : rs1list)
          if (s1.equals(s2)) {
  
          }
  </code></pre>
  
  <p>If these rows are equal I have to print all the row values.</p>