JDK-6220320 : JoinRowSet : Multiple Columns as the MatchColumn does not work
  • Type: Bug
  • Component: core-libs
  • Sub-Component: javax.sql
  • Affected Version: 5.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-01-21
  • Updated: 2010-11-01
  • Resolved: 2007-07-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6u4 b01Fixed
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

Comments
EVALUATION Code needs to be modified such that Join based on multiple columns work .
11-07-2007