JoinRowSet (Java 2 Platform SE 5.0) (original) (raw)


javax.sql.rowset

Interface JoinRowSet

All Superinterfaces:

CachedRowSet, Joinable, ResultSet, RowSet, WebRowSet


public interface JoinRowSet

extends WebRowSet

The JoinRowSet interface provides a mechanism for combining related data from different RowSet objects into one JoinRowSet object, which represents an SQL JOIN. In other words, a JoinRowSet object acts as a container for the data from RowSet objects that form an SQLJOIN relationship.

The Joinable interface provides the methods for setting, retrieving, and unsetting a match column, the basis for establishing an SQL JOIN relationship. The match column may alternatively be set by supplying it to the appropriate version of theJointRowSet method addRowSet.

1.0 Overview

Disconnected RowSet objects (CachedRowSet objects and implementations extending the CachedRowSet interface) do not have a standard way to establish an SQL JOIN between RowSet objects without the expensive operation of reconnecting to the data source. The JoinRowSet interface is specifically designed to address this need.

Any RowSet object can be added to a JoinRowSet object to become part of an SQL JOIN relationship. This means that both connected and disconnected RowSet objects can be part of a JOIN.RowSet objects operating in a connected environment (JdbcRowSet objects) are encouraged to use the database to which they are already connected to establish SQL JOIN relationships between tables directly. However, it is possible for aJdbcRowSet object to be added to a JoinRowSet object if necessary.

Any number of RowSet objects can be added to an instance of JoinRowSet provided that they can be related in an SQL JOIN. By definition, the SQL JOIN statement is used to combine the data contained in two or more relational database tables based upon a common attribute. The Joinable interface provides the methods for establishing a common attribute, which is done by setting a_match column_. The match column commonly coincides with the primary key, but there is no requirement that the match column be the same as the primary key. By establishing and then enforcing column matches, a JoinRowSet object establishes JOIN relationships between RowSet objects without the assistance of an available relational database.

The type of JOIN to be established is determined by setting one of the JoinRowSet constants using the methodsetJoinType. The following SQL JOIN types can be set:

2.0 Using a JoinRowSet Object for Creating a JOIN

When a JoinRowSet object is created, it is empty. The first RowSet object to be added becomes the basis for theJOIN relationship. Applications must determine which column in each of theRowSet objects to be added to the JoinRowSet object should be the match column. All of the RowSet objects must contain a match column, and the values in each match column must be ones that can be compared to values in the other match columns. The columns do not have to have the same name, though they often do, and they do not have to store the exact same data type as long as the data types can be compared.

A match column can be be set in two ways:

3.0 Sample Usage

The following code fragment adds two CachedRowSet objects to a JoinRowSet object. Note that in this example, no SQL JOIN type is set, so the default JOIN type, which is INNER_JOIN, is established.

In the following code fragment, the table EMPLOYEES, whose match column is set to the first column (EMP_ID), is added to theJoinRowSet object jrs. Then the table ESSP_BONUS_PLAN, whose match column is likewise the EMP_ID column, is added. When this second table is added to jrs, only the rows in ESSP_BONUS_PLAN whose EMP_ID value matches anEMP_ID value in the EMPLOYEES table are added. In this case, everyone in the bonus plan is an employee, so all of the rows in the table ESSP_BONUS_PLAN are added to the JoinRowSet object. In this example, both CachedRowSet objects being added have implemented the Joinable interface and can therefore call the Joinable method setMatchColumn.

 JoinRowSet jrs = new JoinRowSetImpl();

 ResultSet rs1 = stmt.executeQuery("SELECT * FROM EMPLOYEES");
 CachedRowSet empl = new CachedRowSetImpl();
 empl.populate(rs1);
 empl.setMatchColumn(1); 
 jrs.addRowSet(empl);

 ResultSet rs2 = stmt.executeQuery("SELECT * FROM ESSP_BONUS_PLAN");
 CachedRowSet bonus = new CachedRowSetImpl();
 bonus.populate(rs2);
 bonus.setMatchColumn(1); // EMP_ID is the first column
 jrs.addRowSet(bonus);

At this point, jrs is an inside JOIN of the two RowSet objects based on their EMP_ID columns. The application can now browse the combined data as if it were browsing one single RowSet object. Because jrs is itself a RowSet object, an application can navigate or modify it using RowSet methods.

 jrs.first();
 int employeeID = jrs.getInt(1);
 String employeeName = jrs.getString(2);

Note that because the SQL JOIN must be enforced when an application adds a second or subsequent RowSet object, there may be an initial degradation in performance while the JOIN is being performed.

The following code fragment adds an additional CachedRowSet object. In this case, the match column (EMP_ID) is set when the CachedRowSet object is added to the JoinRowSet object.

 ResultSet rs3 = stmt.executeQuery("SELECT * FROM 401K_CONTRIB");
 CachedRowSet fourO1k = new CachedRowSetImpl();
 four01k.populate(rs3);
 jrs.addRowSet(four01k, 1);

The JoinRowSet object jrs now contains values from all three tables. The data in each row in four01k in which the value for the EMP_ID column matches a value for the EMP_ID column in jrs has been added to jrs.

4.0 JoinRowSet Methods

The JoinRowSet interface supplies several methods for adding RowSet objects and for getting information about the JoinRowSet object.


Field Summary
static int CROSS_JOIN An ANSI-style JOIN providing a cross product of two tables
static int FULL_JOIN An ANSI-style JOIN providing a a full JOIN.
static int INNER_JOIN An ANSI-style JOIN providing a inner join between two tables.
static int LEFT_OUTER_JOIN An ANSI-style JOIN providing a left outer join between two tables.
static int RIGHT_OUTER_JOIN An ANSI-style JOIN providing a right outer join between two tables.
Fields inherited from interface javax.sql.rowset.WebRowSet
PUBLIC_XML_SCHEMA, SCHEMA_SYSTEM_ID
Fields inherited from interface javax.sql.rowset.CachedRowSet
COMMIT_ON_ACCEPT_CHANGES
Fields inherited from interface java.sql.ResultSet
CLOSE_CURSORS_AT_COMMIT, CONCUR_READ_ONLY, CONCUR_UPDATABLE, FETCH_FORWARD, FETCH_REVERSE, FETCH_UNKNOWN, HOLD_CURSORS_OVER_COMMIT, TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE, TYPE_SCROLL_SENSITIVE
Method Summary
void addRowSet(Joinable rowset) Adds the given RowSet object to this JoinRowSet object.
void [addRowSet](../../../javax/sql/rowset/JoinRowSet.html#addRowSet%28javax.sql.RowSet[], int[]%29)(RowSet[] rowset, int[] columnIdx) Adds one or more RowSet objects contained in the given array of RowSet objects to this JoinRowSet object and sets the match column for each of the RowSet objects to the match columns in the given array of column indexes.
void [addRowSet](../../../javax/sql/rowset/JoinRowSet.html#addRowSet%28javax.sql.RowSet[], java.lang.String[]%29)(RowSet[] rowset,String[] columnName) Adds one or more RowSet objects contained in the given array of RowSet objects to this JoinRowSet object and sets the match column for each of the RowSet objects to the match columns in the given array of column names.
void [addRowSet](../../../javax/sql/rowset/JoinRowSet.html#addRowSet%28javax.sql.RowSet, int%29)(RowSet rowset, int columnIdx) Adds the given RowSet object to this JoinRowSet object and sets the designated column as the match column for the RowSet object.
void [addRowSet](../../../javax/sql/rowset/JoinRowSet.html#addRowSet%28javax.sql.RowSet, java.lang.String%29)(RowSet rowset,String columnName) Adds rowset to this JoinRowSet object and sets the designated column as the match column.
int getJoinType() Returns a int describing the set SQL JOIN type governing this JoinRowSet instance.
String[] getRowSetNames() Returns a String array containing the names of theRowSet objects added to this JoinRowSet object.
Collection<?> getRowSets() Returns a Collection object containing the RowSet objects that have been added to thisJoinRowSet object.
String getWhereClause() Return a SQL-like description of the WHERE clause being used in a JoinRowSet object.
void setJoinType(int joinType) Allow the application to adjust the type of JOIN imposed on tables contained within the JoinRowSet object instance.
boolean supportsCrossJoin() Indicates if CROSS_JOIN is supported by a JoinRowSet implementation
boolean supportsFullJoin() Indicates if FULL_JOIN is supported by a JoinRowSet implementation
boolean supportsInnerJoin() Indicates if INNER_JOIN is supported by a JoinRowSet implementation
boolean supportsLeftOuterJoin() Indicates if LEFT_OUTER_JOIN is supported by a JoinRowSet implementation
boolean supportsRightOuterJoin() Indicates if RIGHT_OUTER_JOIN is supported by a JoinRowSet implementation
CachedRowSet toCachedRowSet() Creates a new CachedRowSet object containing the data in this JoinRowSet object, which can be saved to a data source using the SyncProvider object for the CachedRowSet object.
Methods inherited from interface javax.sql.rowset.WebRowSet
readXml, readXml, writeXml, [writeXml](../../../javax/sql/rowset/WebRowSet.html#writeXml%28java.sql.ResultSet, java.io.OutputStream%29), [writeXml](../../../javax/sql/rowset/WebRowSet.html#writeXml%28java.sql.ResultSet, java.io.Writer%29), writeXml
Methods inherited from interface javax.sql.rowset.CachedRowSet
acceptChanges, acceptChanges, columnUpdated, columnUpdated, commit, createCopy, createCopyNoConstraints, createCopySchema, createShared, execute, getKeyColumns, getOriginal, getOriginalRow, getPageSize, getRowSetWarnings, getShowDeleted, getSyncProvider, getTableName, nextPage, populate, [populate](../../../javax/sql/rowset/CachedRowSet.html#populate%28java.sql.ResultSet, int%29), previousPage, release, restoreOriginal, rollback, rollback, [rowSetPopulated](../../../javax/sql/rowset/CachedRowSet.html#rowSetPopulated%28javax.sql.RowSetEvent, int%29), setKeyColumns, setMetaData, setOriginalRow, setPageSize, setShowDeleted, setSyncProvider, setTableName, size, toCollection, toCollection, toCollection, undoDelete, undoInsert, undoUpdate
Methods inherited from interface javax.sql.RowSet
addRowSetListener, clearParameters, execute, getCommand, getDataSourceName, getEscapeProcessing, getMaxFieldSize, getMaxRows, getPassword, getQueryTimeout, getTransactionIsolation, getTypeMap, getUrl, getUsername, isReadOnly, removeRowSetListener, [setArray](../../../javax/sql/RowSet.html#setArray%28int, java.sql.Array%29), [setAsciiStream](../../../javax/sql/RowSet.html#setAsciiStream%28int, java.io.InputStream, int%29), [setBigDecimal](../../../javax/sql/RowSet.html#setBigDecimal%28int, java.math.BigDecimal%29), [setBinaryStream](../../../javax/sql/RowSet.html#setBinaryStream%28int, java.io.InputStream, int%29), [setBlob](../../../javax/sql/RowSet.html#setBlob%28int, java.sql.Blob%29), [setBoolean](../../../javax/sql/RowSet.html#setBoolean%28int, boolean%29), [setByte](../../../javax/sql/RowSet.html#setByte%28int, byte%29), [setBytes](../../../javax/sql/RowSet.html#setBytes%28int, byte[]%29), [setCharacterStream](../../../javax/sql/RowSet.html#setCharacterStream%28int, java.io.Reader, int%29), [setClob](../../../javax/sql/RowSet.html#setClob%28int, java.sql.Clob%29), setCommand, setConcurrency, setDataSourceName, [setDate](../../../javax/sql/RowSet.html#setDate%28int, java.sql.Date%29), [setDate](../../../javax/sql/RowSet.html#setDate%28int, java.sql.Date, java.util.Calendar%29), [setDouble](../../../javax/sql/RowSet.html#setDouble%28int, double%29), setEscapeProcessing, [setFloat](../../../javax/sql/RowSet.html#setFloat%28int, float%29), [setInt](../../../javax/sql/RowSet.html#setInt%28int, int%29), [setLong](../../../javax/sql/RowSet.html#setLong%28int, long%29), setMaxFieldSize, setMaxRows, [setNull](../../../javax/sql/RowSet.html#setNull%28int, int%29), [setNull](../../../javax/sql/RowSet.html#setNull%28int, int, java.lang.String%29), [setObject](../../../javax/sql/RowSet.html#setObject%28int, java.lang.Object%29), [setObject](../../../javax/sql/RowSet.html#setObject%28int, java.lang.Object, int%29), [setObject](../../../javax/sql/RowSet.html#setObject%28int, java.lang.Object, int, int%29), setPassword, setQueryTimeout, setReadOnly, [setRef](../../../javax/sql/RowSet.html#setRef%28int, java.sql.Ref%29), [setShort](../../../javax/sql/RowSet.html#setShort%28int, short%29), [setString](../../../javax/sql/RowSet.html#setString%28int, java.lang.String%29), [setTime](../../../javax/sql/RowSet.html#setTime%28int, java.sql.Time%29), [setTime](../../../javax/sql/RowSet.html#setTime%28int, java.sql.Time, java.util.Calendar%29), [setTimestamp](../../../javax/sql/RowSet.html#setTimestamp%28int, java.sql.Timestamp%29), [setTimestamp](../../../javax/sql/RowSet.html#setTimestamp%28int, java.sql.Timestamp, java.util.Calendar%29), setTransactionIsolation, setType, setTypeMap, setUrl, setUsername
Methods inherited from interface java.sql.ResultSet
absolute, afterLast, beforeFirst, cancelRowUpdates, clearWarnings, close, deleteRow, findColumn, first, getArray, getArray, getAsciiStream, getAsciiStream, getBigDecimal, [getBigDecimal](../../../java/sql/ResultSet.html#getBigDecimal%28int, int%29), getBigDecimal, [getBigDecimal](../../../java/sql/ResultSet.html#getBigDecimal%28java.lang.String, int%29), getBinaryStream, getBinaryStream, getBlob, getBlob, getBoolean, getBoolean, getByte, getByte, getBytes, getBytes, getCharacterStream, getCharacterStream, getClob, getClob, getConcurrency, getCursorName, getDate, [getDate](../../../java/sql/ResultSet.html#getDate%28int, java.util.Calendar%29), getDate, [getDate](../../../java/sql/ResultSet.html#getDate%28java.lang.String, java.util.Calendar%29), getDouble, getDouble, getFetchDirection, getFetchSize, getFloat, getFloat, getInt, getInt, getLong, getLong, getMetaData, getObject, [getObject](../../../java/sql/ResultSet.html#getObject%28int, java.util.Map%29), getObject, [getObject](../../../java/sql/ResultSet.html#getObject%28java.lang.String, java.util.Map%29), getRef, getRef, getRow, getShort, getShort, getStatement, getString, getString, getTime, [getTime](../../../java/sql/ResultSet.html#getTime%28int, java.util.Calendar%29), getTime, [getTime](../../../java/sql/ResultSet.html#getTime%28java.lang.String, java.util.Calendar%29), getTimestamp, [getTimestamp](../../../java/sql/ResultSet.html#getTimestamp%28int, java.util.Calendar%29), getTimestamp, [getTimestamp](../../../java/sql/ResultSet.html#getTimestamp%28java.lang.String, java.util.Calendar%29), getType, getUnicodeStream, getUnicodeStream, getURL, getURL, getWarnings, insertRow, isAfterLast, isBeforeFirst, isFirst, isLast, last, moveToCurrentRow, moveToInsertRow, next, previous, refreshRow, relative, rowDeleted, rowInserted, rowUpdated, setFetchDirection, setFetchSize, [updateArray](../../../java/sql/ResultSet.html#updateArray%28int, java.sql.Array%29), [updateArray](../../../java/sql/ResultSet.html#updateArray%28java.lang.String, java.sql.Array%29), [updateAsciiStream](../../../java/sql/ResultSet.html#updateAsciiStream%28int, java.io.InputStream, int%29), [updateAsciiStream](../../../java/sql/ResultSet.html#updateAsciiStream%28java.lang.String, java.io.InputStream, int%29), [updateBigDecimal](../../../java/sql/ResultSet.html#updateBigDecimal%28int, java.math.BigDecimal%29), [updateBigDecimal](../../../java/sql/ResultSet.html#updateBigDecimal%28java.lang.String, java.math.BigDecimal%29), [updateBinaryStream](../../../java/sql/ResultSet.html#updateBinaryStream%28int, java.io.InputStream, int%29), [updateBinaryStream](../../../java/sql/ResultSet.html#updateBinaryStream%28java.lang.String, java.io.InputStream, int%29), [updateBlob](../../../java/sql/ResultSet.html#updateBlob%28int, java.sql.Blob%29), [updateBlob](../../../java/sql/ResultSet.html#updateBlob%28java.lang.String, java.sql.Blob%29), [updateBoolean](../../../java/sql/ResultSet.html#updateBoolean%28int, boolean%29), [updateBoolean](../../../java/sql/ResultSet.html#updateBoolean%28java.lang.String, boolean%29), [updateByte](../../../java/sql/ResultSet.html#updateByte%28int, byte%29), [updateByte](../../../java/sql/ResultSet.html#updateByte%28java.lang.String, byte%29), [updateBytes](../../../java/sql/ResultSet.html#updateBytes%28int, byte[]%29), [updateBytes](../../../java/sql/ResultSet.html#updateBytes%28java.lang.String, byte[]%29), [updateCharacterStream](../../../java/sql/ResultSet.html#updateCharacterStream%28int, java.io.Reader, int%29), [updateCharacterStream](../../../java/sql/ResultSet.html#updateCharacterStream%28java.lang.String, java.io.Reader, int%29), [updateClob](../../../java/sql/ResultSet.html#updateClob%28int, java.sql.Clob%29), [updateClob](../../../java/sql/ResultSet.html#updateClob%28java.lang.String, java.sql.Clob%29), [updateDate](../../../java/sql/ResultSet.html#updateDate%28int, java.sql.Date%29), [updateDate](../../../java/sql/ResultSet.html#updateDate%28java.lang.String, java.sql.Date%29), [updateDouble](../../../java/sql/ResultSet.html#updateDouble%28int, double%29), [updateDouble](../../../java/sql/ResultSet.html#updateDouble%28java.lang.String, double%29), [updateFloat](../../../java/sql/ResultSet.html#updateFloat%28int, float%29), [updateFloat](../../../java/sql/ResultSet.html#updateFloat%28java.lang.String, float%29), [updateInt](../../../java/sql/ResultSet.html#updateInt%28int, int%29), [updateInt](../../../java/sql/ResultSet.html#updateInt%28java.lang.String, int%29), [updateLong](../../../java/sql/ResultSet.html#updateLong%28int, long%29), [updateLong](../../../java/sql/ResultSet.html#updateLong%28java.lang.String, long%29), updateNull, updateNull, [updateObject](../../../java/sql/ResultSet.html#updateObject%28int, java.lang.Object%29), [updateObject](../../../java/sql/ResultSet.html#updateObject%28int, java.lang.Object, int%29), [updateObject](../../../java/sql/ResultSet.html#updateObject%28java.lang.String, java.lang.Object%29), [updateObject](../../../java/sql/ResultSet.html#updateObject%28java.lang.String, java.lang.Object, int%29), [updateRef](../../../java/sql/ResultSet.html#updateRef%28int, java.sql.Ref%29), [updateRef](../../../java/sql/ResultSet.html#updateRef%28java.lang.String, java.sql.Ref%29), updateRow, [updateShort](../../../java/sql/ResultSet.html#updateShort%28int, short%29), [updateShort](../../../java/sql/ResultSet.html#updateShort%28java.lang.String, short%29), [updateString](../../../java/sql/ResultSet.html#updateString%28int, java.lang.String%29), [updateString](../../../java/sql/ResultSet.html#updateString%28java.lang.String, java.lang.String%29), [updateTime](../../../java/sql/ResultSet.html#updateTime%28int, java.sql.Time%29), [updateTime](../../../java/sql/ResultSet.html#updateTime%28java.lang.String, java.sql.Time%29), [updateTimestamp](../../../java/sql/ResultSet.html#updateTimestamp%28int, java.sql.Timestamp%29), [updateTimestamp](../../../java/sql/ResultSet.html#updateTimestamp%28java.lang.String, java.sql.Timestamp%29), wasNull
Methods inherited from interface javax.sql.rowset.Joinable
getMatchColumnIndexes, getMatchColumnNames, setMatchColumn, setMatchColumn, setMatchColumn, setMatchColumn, unsetMatchColumn, unsetMatchColumn, unsetMatchColumn, unsetMatchColumn
Field Detail

CROSS_JOIN

static final int CROSS_JOIN

An ANSI-style JOIN providing a cross product of two tables

See Also:

Constant Field Values


INNER_JOIN

static final int INNER_JOIN

An ANSI-style JOIN providing a inner join between two tables. Any unmatched rows in either table of the join should be discarded.

See Also:

Constant Field Values


LEFT_OUTER_JOIN

static final int LEFT_OUTER_JOIN

An ANSI-style JOIN providing a left outer join between two tables. In SQL, this is described where all records should be returned from the left side of the JOIN statement.

See Also:

Constant Field Values


RIGHT_OUTER_JOIN

static final int RIGHT_OUTER_JOIN

An ANSI-style JOIN providing a right outer join between two tables. In SQL, this is described where all records from the table on the right side of the JOIN statement even if the table on the left has no matching record.

See Also:

Constant Field Values


FULL_JOIN

static final int FULL_JOIN

An ANSI-style JOIN providing a a full JOIN. Specifies that all rows from either table be returned regardless of matching records on the other table.

See Also:

Constant Field Values

Method Detail

addRowSet

void addRowSet(Joinable rowset) throws SQLException

Adds the given RowSet object to this JoinRowSet object. If the RowSet object is the first to be added to this JoinRowSet object, it forms the basis of the JOIN relationship to be established.

This method should be used only when the given RowSet object already has a match column that was set with the Joinable method setMatchColumn.

Note: A Joinable object is any RowSet object that has implemented the Joinable interface.

Parameters:

rowset - the RowSet object that is to be added to thisJoinRowSet object; it must implement the Joinable interface and have a match column set

Throws:

[SQLException](../../../java/sql/SQLException.html "class in java.sql") - if (1) an empty rowset is added to the to thisJoinRowSet object, (2) a match column has not been set for rowset, or (3) rowset violates the active JOIN

See Also:

Joinable.setMatchColumn(int)


addRowSet

void addRowSet(RowSet rowset, int columnIdx) throws SQLException

Adds the given RowSet object to this JoinRowSet object and sets the designated column as the match column for the RowSet object. If the RowSet object is the first to be added to this JoinRowSet object, it forms the basis of the JOIN relationship to be established.

This method should be used when RowSet does not already have a match column set.

Parameters:

rowset - the RowSet object that is to be added to thisJoinRowSet object; it may implement the Joinable interface

columnIdx - an int that identifies the column to become the match column

Throws:

[SQLException](../../../java/sql/SQLException.html "class in java.sql") - if (1) rowset is an empty rowset or (2) rowset violates the active JOIN

See Also:

Joinable.unsetMatchColumn(int)


addRowSet

void addRowSet(RowSet rowset, String columnName) throws SQLException

Adds rowset to this JoinRowSet object and sets the designated column as the match column. If rowset is the first to be added to this JoinRowSet object, it forms the basis for the JOIN relationship to be established.

This method should be used when the given RowSet object does not already have a match column.

Parameters:

rowset - the RowSet object that is to be added to thisJoinRowSet object; it may implement the Joinable interface

columnName - the String object giving the name of the column to be set as the match column

Throws:

[SQLException](../../../java/sql/SQLException.html "class in java.sql") - if (1) rowset is an empty rowset or (2) the match column for rowset does not satisfy the conditions of the JOIN


addRowSet

void addRowSet(RowSet[] rowset, int[] columnIdx) throws SQLException

Adds one or more RowSet objects contained in the given array of RowSet objects to this JoinRowSet object and sets the match column for each of the RowSet objects to the match columns in the given array of column indexes. The first element in columnIdx is set as the match column for the firstRowSet object in rowset, the second element of_columnIdx_ is set as the match column for the second element in rowset, and so on.

The first RowSet object added to this JoinRowSet object forms the basis for the JOIN relationship.

This method should be used when the given RowSet object does not already have a match column.

Parameters:

rowset - an array of one or more RowSet objects to be added to the JOIN; it may implement the Joinable interface

columnIdx - an array of int values indicating the index(es) of the columns to be set as the match columns for the RowSet objects in rowset

Throws:

[SQLException](../../../java/sql/SQLException.html "class in java.sql") - if (1) an empty rowset is added to this JoinRowSet object, (2) a match column is not set for a RowSet object in rowset, or (3) a RowSet object being added violates the activeJOIN


addRowSet

void addRowSet(RowSet[] rowset, String[] columnName) throws SQLException

Adds one or more RowSet objects contained in the given array of RowSet objects to this JoinRowSet object and sets the match column for each of the RowSet objects to the match columns in the given array of column names. The first element in columnName is set as the match column for the firstRowSet object in rowset, the second element of_columnName_ is set as the match column for the second element in rowset, and so on.

The first RowSet object added to this JoinRowSet object forms the basis for the JOIN relationship.

This method should be used when the given RowSet object(s) does not already have a match column.

Parameters:

rowset - an array of one or more RowSet objects to be added to the JOIN; it may implement the Joinable interface

columnName - an array of String values indicating the names of the columns to be set as the match columns for the RowSet objects in rowset

Throws:

[SQLException](../../../java/sql/SQLException.html "class in java.sql") - if (1) an empty rowset is added to this JoinRowSet object, (2) a match column is not set for a RowSet object in rowset, or (3) a RowSet object being added violates the activeJOIN


getRowSets

Collection<?> getRowSets() throws SQLException

Returns a Collection object containing the RowSet objects that have been added to thisJoinRowSet object. This should return the 'n' number of RowSet contained within the JOIN and maintain any updates that have occured while in this union.

Returns:

a Collection object consisting of the RowSet objects added to this JoinRowSet object

Throws:

[SQLException](../../../java/sql/SQLException.html "class in java.sql") - if an error occurs generating the Collection object to be returned


getRowSetNames

String[] getRowSetNames() throws SQLException

Returns a String array containing the names of theRowSet objects added to this JoinRowSet object.

Returns:

a String array of the names of theRowSet objects in this JoinRowSet object

Throws:

[SQLException](../../../java/sql/SQLException.html "class in java.sql") - if an error occurs retrieving the names of the RowSet objects

See Also:

CachedRowSet.setTableName(java.lang.String)


toCachedRowSet

CachedRowSet toCachedRowSet() throws SQLException

Creates a new CachedRowSet object containing the data in this JoinRowSet object, which can be saved to a data source using the SyncProvider object for the CachedRowSet object.

If any updates or modifications have been applied to the JoinRowSet the CachedRowSet returned by the method will not be able to persist it's changes back to the originating rows and tables in the in the datasource. The CachedRowSet instance returned should not contain modification data and it should clear all properties of it's originating SQL statement. An application should reset the SQL statement using the RowSet.setCommand method.

In order to allow changes to be persisted back to the datasource to the originating tables, the acceptChanges method should be used and called on a JoinRowSet object instance. Implementations can leverage the internal data and update tracking in their implementations to interact with the SyncProvider to persist any changes.

Returns:

a CachedRowSet containing the contents of the JoinRowSet

Throws:

[SQLException](../../../java/sql/SQLException.html "class in java.sql") - if an error occurs assembling the CachedRowSet object

See Also:

RowSet, CachedRowSet, SyncProvider


supportsCrossJoin

boolean supportsCrossJoin()

Indicates if CROSS_JOIN is supported by a JoinRowSet implementation

Returns:

true if the CROSS_JOIN is supported; false otherwise


supportsInnerJoin

boolean supportsInnerJoin()

Indicates if INNER_JOIN is supported by a JoinRowSet implementation

Returns:

true is the INNER_JOIN is supported; false otherwise


supportsLeftOuterJoin

boolean supportsLeftOuterJoin()

Indicates if LEFT_OUTER_JOIN is supported by a JoinRowSet implementation

Returns:

true is the LEFT_OUTER_JOIN is supported; false otherwise


supportsRightOuterJoin

boolean supportsRightOuterJoin()

Indicates if RIGHT_OUTER_JOIN is supported by a JoinRowSet implementation

Returns:

true is the RIGHT_OUTER_JOIN is supported; false otherwise


supportsFullJoin

boolean supportsFullJoin()

Indicates if FULL_JOIN is supported by a JoinRowSet implementation

Returns:

true is the FULL_JOIN is supported; false otherwise


setJoinType

void setJoinType(int joinType) throws SQLException

Allow the application to adjust the type of JOIN imposed on tables contained within the JoinRowSet object instance. Implementations should throw a SQLException if they do not support a given JOIN type.

Parameters:

joinType - the standard JoinRowSet.XXX static field definition of a SQL JOIN to re-configure a JoinRowSet instance on the fly.

Throws:

[SQLException](../../../java/sql/SQLException.html "class in java.sql") - if an unsupported JOIN type is set

See Also:

getJoinType()


getWhereClause

String getWhereClause() throws SQLException

Return a SQL-like description of the WHERE clause being used in a JoinRowSet object. An implementation can describe the WHERE clause of the SQL JOIN by supplying a SQL strings description of JOIN or provide a textual description to assist applications using a JoinRowSet

Returns:

whereClause a textual or SQL description of the logical WHERE clause used in the JoinRowSet instance

Throws:

[SQLException](../../../java/sql/SQLException.html "class in java.sql") - if an error occurs in generating a representation of the WHERE clause.


getJoinType

int getJoinType() throws SQLException

Returns a int describing the set SQL JOIN type governing this JoinRowSet instance. The returned type will be one of standard JoinRowSet types: CROSS_JOIN, INNER_JOIN, LEFT_OUTER_JOIN, RIGHT_OUTER_JOIN or FULL_JOIN.

Returns:

joinType one of the standard JoinRowSet static field definitions of a SQL JOIN. JoinRowSet.INNER_JOIN is returned as the default JOIN type is no type has been explicitly set.

Throws:

[SQLException](../../../java/sql/SQLException.html "class in java.sql") - if an error occurs determining the SQL JOIN type supported by the JoinRowSet instance.

See Also:

setJoinType(int)



Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Copyright © 2004, 2010 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.