users@glassfish.java.net

getMetadata from JoinRowSet give mistaked informations

From: <glassfish_at_javadesktop.org>
Date: Thu, 07 Jun 2007 02:55:07 PDT

Hi,
I’m using com.sun.rowset to build a cached cursor on a join by two tables.

TargetTableCursorJoin = new JoinRowSetImpl(); //This is mine join-cursor

ResultSet TargetTableResultSet = stp.executeQuery(SQL_Statement);
                                                //This is mine resultset by first
                                                //table (stp is a statement of a connection)

CachedRowSet TargetTableCursor = new CachedRowSetImpl();
TargetTableCursor.setTableName(Table_Name_1);
TargetTableCursor.setKeyColumns(TableDefinition.GetKey());
TargetTableCursor.populate(TargetTableResultSet);
TargetTableCursor.setMatchColumn(Table1Key);
                                                //Here I build and populate mine first
                                                //cachedRowset with the resultset of first
                                                //table
TargetTableCursorJoin.addRowSet(TargetTableCursor);
//Add the first c.r. at join r.s.

Make the same thing with second table. The result is a JoinRowSet of join by the two table on the selected (Match)column.

The ERROR is into the java.sql.Resultset.getMetadata method.

TargetTableCursorJoin.getMetaData() is a collect with:

name of table columns
type of date into columns
label of columns
etc.

But this informations is correct only for the first table with the match column of the first table renamed “MatchColumn”.

The metadata of the second table are correct since the match-column, the others are mistached:

ResultSetMetaData TableDescriptor = TargetTableCursorJoin.getMetaData();

contains..

TableDescriptor.getColumnName(i) column name

TableDescriptor.getColumnLabel(i) column label
                                                                          TableDescriptor.getColumnTypeName(i) column data type
                                                                          TableDescriptor.getColumnClassName(i) column class name
                                                                          
TargetTableCursorJoin.getObject(i) column data

Correct until "i" is a column of the first table or "i" is a column of the second table before the match-column. When "i" is the match-column of the second table the metadata values are:

TableDescriptor.getColumnName(i) column name = the name of the next column
                                                                       
TableDescriptor.getColumnLabel(i) column label = NULL

TableDescriptor.getColumnTypeName(i) column data type = NULL
                                                                          TableDescriptor.getColumnClassName(i) column class name = NULL
                                                                          
TargetTableCursorJoin.getObject(i) column data = NULL


The other metadata are disaligned:

TableDescriptor.getColumnName(i) column name = the name of the next column

TableDescriptor.getColumnLabel(i) column label

TableDescriptor.getColumnTypeName(i) column data type = the type of
                                                                the next column
                                                                          TableDescriptor.getColumnClassName(i) column class name

TargetTableCursorJoin.getObject(i) column data = the value of the
                                                                next column


Please help me.
[Message sent by forum member 'fchiri' (fchiri)]

http://forums.java.net/jive/thread.jspa?messageID=220936