Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6220320

JoinRowSet : Multiple Columns as the MatchColumn does not work

    Details

    • Subcomponent:
    • Resolved In Build:
      b01
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      java version "1.5.0_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
      Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      JoinRowSet : Multiple Columns as the MatchColumn

      The spec for Joinable seems to suggest that multiple match columns are possible, however the JoinRowSet seems to be have a limitation for one match column only.

      Any possible example to do it within the JoinRowSet APIs as I may only able to due with disconnected CachedRowSet.

      I spent one day and have been trying to join two tables with two columns as a JOIN match but could not make anything work. I read all the doc and the JDBC RowSet Implementations Tutorial doesn't really help a lot. My understanding is that no matter how many indexes I used in setMatchColumn(idArray); it will only take 1st index as the matching column.

      Any example will be appreciated.

      Connection con = DriverManager.getConnection(dbUrl,dbUserId,dbPasswd);

      Statement stmt8 = con.createStatement();
      ResultSet rs = stmt8.executeQuery("select project_id, bld_id, bld_name from table1");


      Statement stmt10 = con.createStatement();
      ResultSet rs3 = stmt10.executeQuery("select project_id, bld_id, project_name from table2");


      CachedRowSet crs3 = new CachedRowSetImpl();

      crs3.populate( rs);


      System.out.println("Size of the first cached rowset is:: "+crs3.size());


      CachedRowSet crs4 = new CachedRowSetImpl();

      rs.beforeFirst();
      crs4.populate( rs);

      System.out.println("Size of the first cached rowset is:: "+crs4.size());

      JoinRowSet jrs = new JoinRowSetImpl();

      System.out.println("Adding 1st crs :: "+crs3.size());


      int [] idArray = {1,2};
      crs3.setMatchColumn(idArray);
      jrs.addRowSet(crs3);

      crs4.setMatchColumn(idArray);
      jrs.addRowSet(crs4);

      FileWriter fWriter;
      fWriter = new FileWriter("myoutput.xml");
      jrs.writeXml(fWriter);
      fWriter.flush();
      fWriter.close();


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Connection con = DriverManager.getConnection(dbUrl,dbUserId,dbPasswd);

      Statement stmt8 = con.createStatement();
      ResultSet rs = stmt8.executeQuery("select project_id, bld_id, bld_name from table1");


      Statement stmt10 = con.createStatement();
      ResultSet rs3 = stmt10.executeQuery("select project_id, bld_id, project_name from table2");


      CachedRowSet crs3 = new CachedRowSetImpl();

      crs3.populate( rs);


      System.out.println("Size of the first cached rowset is:: "+crs3.size());


      CachedRowSet crs4 = new CachedRowSetImpl();

      rs.beforeFirst();
      crs4.populate( rs);

      System.out.println("Size of the first cached rowset is:: "+crs4.size());

      JoinRowSet jrs = new JoinRowSetImpl();

      System.out.println("Adding 1st crs :: "+crs3.size());


      int [] idArray = {1,2};
      crs3.setMatchColumn(idArray);
      jrs.addRowSet(crs3);

      crs4.setMatchColumn(idArray);
      jrs.addRowSet(crs4);

      FileWriter fWriter;
      fWriter = new FileWriter("myoutput.xml");
      jrs.writeXml(fWriter);
      fWriter.flush();
      fWriter.close();


      REPRODUCIBILITY :
      This bug can be reproduced always.
      ###@###.### 2005-1-21 23:12:31 GMT

        Attachments

          Activity

            People

            • Assignee:
              ahandasunw Amit Handa (Inactive)
              Reporter:
              gmanwanisunw Girish Manwani (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: