| java.lang.Object net.sourceforge.jtds.jdbc.JtdsResultSet net.sourceforge.jtds.jdbc.CachedResultSet
CachedResultSet | public class CachedResultSet extends JtdsResultSet (Code) | | A memory cached scrollable/updateable result set.
Notes:
- For maximum performance use the scroll insensitive result set type.
- As the result set is cached in memory this implementation is limited
to small result sets.
- Updateable or scroll sensitive result sets are limited to selects
which reference one table only.
- Scroll sensitive result sets must have primary keys.
- Updates are optimistic. To guard against lost updates it is
recommended that the table includes a timestamp column.
- This class is a plug-in replacement for the MSCursorResultSet class
which may be advantageous in certain applications as the scroll
insensitive result set implemented here is much faster than the server
side cursor.
- Updateable result sets cannot be built from the output of stored
procedures.
- This implementation uses 'select ... for browse' to obtain the column
meta data needed to generate update statements etc.
- Named forward updateable cursors are also supported in which case
positioned updates and deletes are used referencing a server side
declared cursor.
- Named forward read only declared cursors can have a larger fetch size
specified allowing a cursor alternative to the default direct select
method.
author: Mike Hutchinson version: $Id: CachedResultSet.java,v 1.26 2007/07/08 17:28:23 bheineman Exp $ |
Constructor Summary | |
| CachedResultSet(JtdsStatement statement, String sql, String procName, ParamInfo[] procedureParams, int resultSetType, int concurrency) Constructs a new cached result set.
This result set will either be cached in memory or, if the cursor name
is set, can be a forward only server side cursor. | | CachedResultSet(JtdsStatement statement, String[] colName, int[] colType) Constructs a cached result set based on locally generated data. | | CachedResultSet(JtdsResultSet rs, boolean load) Creates a cached result set with the same columns (and optionally data)
as an existing result set. | | CachedResultSet(JtdsStatement statement, ColInfo columns, Object data) Creates a cached result set containing one row. |
cursorTds | final protected TdsCore cursorTds(Code) | | Cursor TdsCore object.
|
initialRowCnt | protected int initialRowCnt(Code) | | The row count of the initial result set.
|
insertRow | protected ParamInfo[] insertRow(Code) | | Buffer row used for inserts.
|
isKeyed | protected boolean isKeyed(Code) | | Table is keyed.
|
isSybase | protected boolean isSybase(Code) | | Flag to indicate Sybase.
|
onInsertRow | protected boolean onInsertRow(Code) | | Indicates currently inserting.
|
procName | final protected String procName(Code) | | Original procedure name.
|
procedureParams | final protected ParamInfo[] procedureParams(Code) | | Original parameters.
|
rowDeleted | protected boolean rowDeleted(Code) | | Indicates that row has been deleted.
|
rowUpdated | protected boolean rowUpdated(Code) | | Indicates that row has been updated.
|
sizeChanged | protected boolean sizeChanged(Code) | | Fetch size has been changed.
|
tableName | protected String tableName(Code) | | First table name in select.
|
tempResultSet | final protected boolean tempResultSet(Code) | | True if this is a local temporary result set.
|
updateTds | final protected TdsCore updateTds(Code) | | Updates TdsCore object used for positioned updates.
|
CachedResultSet | CachedResultSet(JtdsStatement statement, String sql, String procName, ParamInfo[] procedureParams, int resultSetType, int concurrency) throws SQLException(Code) | | Constructs a new cached result set.
This result set will either be cached in memory or, if the cursor name
is set, can be a forward only server side cursor. This latter form of
cursor can also support positioned updates.
Parameters: statement - the parent statement object Parameters: sql - the SQL statement used to build the result set Parameters: procName - an optional stored procedure name Parameters: procedureParams - parameters for prepared statements Parameters: resultSetType - the result set type eg scrollable Parameters: concurrency - the result set concurrency eg updateable exception: SQLException - if an error occurs |
CachedResultSet | CachedResultSet(JtdsStatement statement, String[] colName, int[] colType) throws SQLException(Code) | | Constructs a cached result set based on locally generated data.
Parameters: statement - the parent statement object Parameters: colName - array of column names Parameters: colType - array of corresponding data types exception: SQLException - if an error occurs |
CachedResultSet | CachedResultSet(JtdsResultSet rs, boolean load) throws SQLException(Code) | | Creates a cached result set with the same columns (and optionally data)
as an existing result set.
Parameters: rs - the result set to copy Parameters: load - load data from the supplied result set throws: SQLException - if an error occurs |
CachedResultSet | CachedResultSet(JtdsStatement statement, ColInfo columns, Object data) throws SQLException(Code) | | Creates a cached result set containing one row.
Parameters: statement - the parent statement object Parameters: columns - the column descriptor array Parameters: data - the row data throws: SQLException - if an error occurs |
buildParameter | protected static ParamInfo buildParameter(int pos, ColInfo info, Object value, boolean isUnicode) throws SQLException(Code) | | Creates a parameter object for an UPDATE, DELETE or INSERT statement.
Parameters: pos - the substitution position of the parameter marker in the SQL Parameters: info - the ColInfo column descriptor Parameters: value - the column data item the new parameter as a ParamInfo object |
buildWhereClause | ParamInfo[] buildWhereClause(StringBuffer sql, ArrayList params, boolean select) throws SQLException(Code) | | Builds a WHERE clause for UPDATE or DELETE statements.
Parameters: sql - the SQL Statement to append the WHERE clause to Parameters: params - the parameter descriptor array for this statement Parameters: select - true if this WHERE clause will be used in a selectstatement the parameter list as a ParamInfo[] throws: SQLException - if an error occurs |
isCursorUpdateable | boolean isCursorUpdateable() throws SQLException(Code) | | Analyses the tables in the result set and determines if the primary key
columns needed to make it updateable exist.
Sybase (and SQL 6.5) will automatically include any additional key and
timestamp columns as hidden fields even if the user does not reference
them in the select statement.
If the table is unkeyed but there is an identity column then this is
promoted to a key.
Alternatively we can update, provided all the columns in the table row
have been selected, by regarding all of them as keys.
SQL Server 7+ does not return the correct primary key meta data for
temporary tables so the driver has to query the catalog to locate any
keys.
true if there is one table and it is keyed |
refreshKeyedRows | protected void refreshKeyedRows() throws SQLException(Code) | | Refreshes a result set row from keyed tables.
If all the tables in the result set have primary keys then the result
set row can be refreshed by refetching the individual table rows.
throws: SQLException - if an error occurs |
refreshReRead | protected void refreshReRead() throws SQLException(Code) | | Refreshes the row by rereading the result set.
Obviously very slow on large result sets but may be the only option if
tables do not have keys.
|
setColValue | protected Object setColValue(int colIndex, int jdbcType, Object value, int length) throws SQLException(Code) | | Sets the specified column's data value.
Parameters: colIndex - index of the column Parameters: value - new column value the value, possibly converted to an internal type |
setConcurrency | void setConcurrency(int concurrency)(Code) | | Modify the concurrency of the result set.
Use to make result set read only once loaded.
Parameters: concurrency - the concurrency value egResultSet.CONCUR_READ_ONLY |
Methods inherited from net.sourceforge.jtds.jdbc.JtdsResultSet | public boolean absolute(int row) throws SQLException(Code)(Java Doc) public void afterLast() throws SQLException(Code)(Java Doc) public void beforeFirst() throws SQLException(Code)(Java Doc) protected void cacheResultSetRows() throws SQLException(Code)(Java Doc) public void cancelRowUpdates() throws SQLException(Code)(Java Doc) protected void checkOpen() throws SQLException(Code)(Java Doc) protected void checkScrollable() throws SQLException(Code)(Java Doc) protected void checkUpdateable() throws SQLException(Code)(Java Doc) public void clearWarnings() throws SQLException(Code)(Java Doc) public void close() throws SQLException(Code)(Java Doc) protected ColInfo[] copyInfo(ColInfo[] info)(Code)(Java Doc) protected Object[] copyRow(Object[] row)(Code)(Java Doc) public void deleteRow() throws SQLException(Code)(Java Doc) public int findColumn(String columnName) throws SQLException(Code)(Java Doc) public boolean first() throws SQLException(Code)(Java Doc) public Array getArray(int columnIndex) throws SQLException(Code)(Java Doc) public Array getArray(String columnName) throws SQLException(Code)(Java Doc) public InputStream getAsciiStream(int columnIndex) throws SQLException(Code)(Java Doc) public InputStream getAsciiStream(String columnName) throws SQLException(Code)(Java Doc) public BigDecimal getBigDecimal(int columnIndex) throws SQLException(Code)(Java Doc) public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException(Code)(Java Doc) public BigDecimal getBigDecimal(String columnName) throws SQLException(Code)(Java Doc) public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException(Code)(Java Doc) public InputStream getBinaryStream(int columnIndex) throws SQLException(Code)(Java Doc) public InputStream getBinaryStream(String columnName) throws SQLException(Code)(Java Doc) public Blob getBlob(int columnIndex) throws SQLException(Code)(Java Doc) public Blob getBlob(String columnName) throws SQLException(Code)(Java Doc) public boolean getBoolean(int columnIndex) throws SQLException(Code)(Java Doc) public boolean getBoolean(String columnName) throws SQLException(Code)(Java Doc) public byte getByte(int columnIndex) throws SQLException(Code)(Java Doc) public byte getByte(String columnName) throws SQLException(Code)(Java Doc) public byte[] getBytes(int columnIndex) throws SQLException(Code)(Java Doc) public byte[] getBytes(String columnName) throws SQLException(Code)(Java Doc) public Reader getCharacterStream(int columnIndex) throws SQLException(Code)(Java Doc) public Reader getCharacterStream(String columnName) throws SQLException(Code)(Java Doc) public Clob getClob(int columnIndex) throws SQLException(Code)(Java Doc) public Clob getClob(String columnName) throws SQLException(Code)(Java Doc) protected Object getColumn(int index) throws SQLException(Code)(Java Doc) protected static int getColumnCount(ColInfo[] columns)(Code)(Java Doc) protected ColInfo[] getColumns()(Code)(Java Doc) public int getConcurrency() throws SQLException(Code)(Java Doc) protected Object[] getCurrentRow()(Code)(Java Doc) public String getCursorName() throws SQLException(Code)(Java Doc) public Date getDate(int columnIndex) throws SQLException(Code)(Java Doc) public Date getDate(String columnName) throws SQLException(Code)(Java Doc) public Date getDate(int columnIndex, Calendar cal) throws SQLException(Code)(Java Doc) public Date getDate(String columnName, Calendar cal) throws SQLException(Code)(Java Doc) public double getDouble(int columnIndex) throws SQLException(Code)(Java Doc) public double getDouble(String columnName) throws SQLException(Code)(Java Doc) public int getFetchDirection() throws SQLException(Code)(Java Doc) public int getFetchSize() throws SQLException(Code)(Java Doc) public float getFloat(int columnIndex) throws SQLException(Code)(Java Doc) public float getFloat(String columnName) throws SQLException(Code)(Java Doc) public int getInt(int columnIndex) throws SQLException(Code)(Java Doc) public int getInt(String columnName) throws SQLException(Code)(Java Doc) public long getLong(int columnIndex) throws SQLException(Code)(Java Doc) public long getLong(String columnName) throws SQLException(Code)(Java Doc) public ResultSetMetaData getMetaData() throws SQLException(Code)(Java Doc) public Object getObject(int columnIndex) throws SQLException(Code)(Java Doc) public Object getObject(String columnName) throws SQLException(Code)(Java Doc) public Object getObject(int columnIndex, Map map) throws SQLException(Code)(Java Doc) public Object getObject(String columnName, Map map) throws SQLException(Code)(Java Doc) public Ref getRef(int columnIndex) throws SQLException(Code)(Java Doc) public Ref getRef(String columnName) throws SQLException(Code)(Java Doc) public int getRow() throws SQLException(Code)(Java Doc) public short getShort(int columnIndex) throws SQLException(Code)(Java Doc) public short getShort(String columnName) throws SQLException(Code)(Java Doc) public Statement getStatement() throws SQLException(Code)(Java Doc) public String getString(int columnIndex) throws SQLException(Code)(Java Doc) public String getString(String columnName) throws SQLException(Code)(Java Doc) public Time getTime(int columnIndex) throws SQLException(Code)(Java Doc) public Time getTime(String columnName) throws SQLException(Code)(Java Doc) public Time getTime(int columnIndex, Calendar cal) throws SQLException(Code)(Java Doc) public Time getTime(String columnName, Calendar cal) throws SQLException(Code)(Java Doc) public Timestamp getTimestamp(int columnIndex) throws SQLException(Code)(Java Doc) public Timestamp getTimestamp(String columnName) throws SQLException(Code)(Java Doc) public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException(Code)(Java Doc) public Timestamp getTimestamp(String columnName, Calendar cal) throws SQLException(Code)(Java Doc) public int getType() throws SQLException(Code)(Java Doc) public URL getURL(int columnIndex) throws SQLException(Code)(Java Doc) public URL getURL(String columnName) throws SQLException(Code)(Java Doc) public InputStream getUnicodeStream(int columnIndex) throws SQLException(Code)(Java Doc) public InputStream getUnicodeStream(String columnName) throws SQLException(Code)(Java Doc) public SQLWarning getWarnings() throws SQLException(Code)(Java Doc) public void insertRow() throws SQLException(Code)(Java Doc) public boolean isAfterLast() throws SQLException(Code)(Java Doc) public boolean isBeforeFirst() throws SQLException(Code)(Java Doc) public boolean isFirst() throws SQLException(Code)(Java Doc) public boolean isLast() throws SQLException(Code)(Java Doc) public boolean last() throws SQLException(Code)(Java Doc) public void moveToCurrentRow() throws SQLException(Code)(Java Doc) public void moveToInsertRow() throws SQLException(Code)(Java Doc) protected Object[] newRow()(Code)(Java Doc) public boolean next() throws SQLException(Code)(Java Doc) protected static void notImplemented(String method) throws SQLException(Code)(Java Doc) public boolean previous() throws SQLException(Code)(Java Doc) public void refreshRow() throws SQLException(Code)(Java Doc) public boolean relative(int row) throws SQLException(Code)(Java Doc) public boolean rowDeleted() throws SQLException(Code)(Java Doc) public boolean rowInserted() throws SQLException(Code)(Java Doc) public boolean rowUpdated() throws SQLException(Code)(Java Doc) protected void setColLabel(int colIndex, String name)(Code)(Java Doc) protected void setColName(int colIndex, String name)(Code)(Java Doc) protected void setColType(int colIndex, int jdbcType)(Code)(Java Doc) protected Object setColValue(int colIndex, int jdbcType, Object value, int length) throws SQLException(Code)(Java Doc) protected void setColumnCount(int columnCount)(Code)(Java Doc) public void setFetchDirection(int direction) throws SQLException(Code)(Java Doc) public void setFetchSize(int rows) throws SQLException(Code)(Java Doc) public void updateArray(int columnIndex, Array x) throws SQLException(Code)(Java Doc) public void updateArray(String columnName, Array x) throws SQLException(Code)(Java Doc) public void updateAsciiStream(int columnIndex, InputStream inputStream, int length) throws SQLException(Code)(Java Doc) public void updateAsciiStream(String columnName, InputStream x, int length) throws SQLException(Code)(Java Doc) public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException(Code)(Java Doc) public void updateBigDecimal(String columnName, BigDecimal x) throws SQLException(Code)(Java Doc) public void updateBinaryStream(int columnIndex, InputStream inputStream, int length) throws SQLException(Code)(Java Doc) public void updateBinaryStream(String columnName, InputStream x, int length) throws SQLException(Code)(Java Doc) public void updateBlob(int columnIndex, Blob x) throws SQLException(Code)(Java Doc) public void updateBlob(String columnName, Blob x) throws SQLException(Code)(Java Doc) public void updateBoolean(int columnIndex, boolean x) throws SQLException(Code)(Java Doc) public void updateBoolean(String columnName, boolean x) throws SQLException(Code)(Java Doc) public void updateByte(int columnIndex, byte x) throws SQLException(Code)(Java Doc) public void updateByte(String columnName, byte x) throws SQLException(Code)(Java Doc) public void updateBytes(int columnIndex, byte[] x) throws SQLException(Code)(Java Doc) public void updateBytes(String columnName, byte[] x) throws SQLException(Code)(Java Doc) public void updateCharacterStream(int columnIndex, Reader reader, int length) throws SQLException(Code)(Java Doc) public void updateCharacterStream(String columnName, Reader x, int length) throws SQLException(Code)(Java Doc) public void updateClob(int columnIndex, Clob x) throws SQLException(Code)(Java Doc) public void updateClob(String columnName, Clob x) throws SQLException(Code)(Java Doc) public void updateDate(int columnIndex, Date x) throws SQLException(Code)(Java Doc) public void updateDate(String columnName, Date x) throws SQLException(Code)(Java Doc) public void updateDouble(int columnIndex, double x) throws SQLException(Code)(Java Doc) public void updateDouble(String columnName, double x) throws SQLException(Code)(Java Doc) public void updateFloat(int columnIndex, float x) throws SQLException(Code)(Java Doc) public void updateFloat(String columnName, float x) throws SQLException(Code)(Java Doc) public void updateInt(int columnIndex, int x) throws SQLException(Code)(Java Doc) public void updateInt(String columnName, int x) throws SQLException(Code)(Java Doc) public void updateLong(int columnIndex, long x) throws SQLException(Code)(Java Doc) public void updateLong(String columnName, long x) throws SQLException(Code)(Java Doc) public void updateNull(int columnIndex) throws SQLException(Code)(Java Doc) public void updateNull(String columnName) throws SQLException(Code)(Java Doc) public void updateObject(int columnIndex, Object x) throws SQLException(Code)(Java Doc) public void updateObject(int columnIndex, Object x, int scale) throws SQLException(Code)(Java Doc) public void updateObject(String columnName, Object x) throws SQLException(Code)(Java Doc) public void updateObject(String columnName, Object x, int scale) throws SQLException(Code)(Java Doc) public void updateRef(int columnIndex, Ref x) throws SQLException(Code)(Java Doc) public void updateRef(String columnName, Ref x) throws SQLException(Code)(Java Doc) public void updateRow() throws SQLException(Code)(Java Doc) public void updateShort(int columnIndex, short x) throws SQLException(Code)(Java Doc) public void updateShort(String columnName, short x) throws SQLException(Code)(Java Doc) public void updateString(int columnIndex, String x) throws SQLException(Code)(Java Doc) public void updateString(String columnName, String x) throws SQLException(Code)(Java Doc) public void updateTime(int columnIndex, Time x) throws SQLException(Code)(Java Doc) public void updateTime(String columnName, Time x) throws SQLException(Code)(Java Doc) public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException(Code)(Java Doc) public void updateTimestamp(String columnName, Timestamp x) throws SQLException(Code)(Java Doc) public boolean wasNull() throws SQLException(Code)(Java Doc)
|
|
|