📄 jtdsresultset.java
字号:
public int getType() throws SQLException {
checkOpen();
return resultSetType;
}
public void afterLast() throws SQLException {
checkOpen();
checkScrollable();
}
public void beforeFirst() throws SQLException {
checkOpen();
checkScrollable();
}
public void cancelRowUpdates() throws SQLException {
checkOpen();
checkUpdateable();
}
public void clearWarnings() throws SQLException {
checkOpen();
statement.clearWarnings();
}
public void close() throws SQLException {
if (!closed) {
try {
if (!getConnection().isClosed()) {
// Skip to end of result set
// Could send cancel but this is safer as
// cancel could kill other statements in a batch.
while (next());
}
} finally {
closed = true;
statement = null;
}
}
}
public void deleteRow() throws SQLException {
checkOpen();
checkUpdateable();
}
public void insertRow() throws SQLException {
checkOpen();
checkUpdateable();
}
public void moveToCurrentRow() throws SQLException {
checkOpen();
checkUpdateable();
}
public void moveToInsertRow() throws SQLException {
checkOpen();
checkUpdateable();
}
public void refreshRow() throws SQLException {
checkOpen();
checkUpdateable();
}
public void updateRow() throws SQLException {
checkOpen();
checkUpdateable();
}
public boolean first() throws SQLException {
checkOpen();
checkScrollable();
return false;
}
public boolean isAfterLast() throws SQLException {
checkOpen();
return (pos == POS_AFTER_LAST) && (rowsInResult != 0);
}
public boolean isBeforeFirst() throws SQLException {
checkOpen();
return (pos == POS_BEFORE_FIRST) && (rowsInResult != 0);
}
public boolean isFirst() throws SQLException {
checkOpen();
return pos == 1;
}
public boolean isLast() throws SQLException {
checkOpen();
if (statement.getTds().isDataInResultSet()) {
rowsInResult = pos + 1; // Keep rowsInResult 1 ahead of pos
}
return (pos == rowsInResult) && (rowsInResult != 0);
}
public boolean last() throws SQLException {
checkOpen();
checkScrollable();
return false;
}
public boolean next() throws SQLException {
checkOpen();
if (pos == POS_AFTER_LAST) {
// Make sure nothing will happen after the end has been reached
return false;
}
if (rowData != null) {
// The rest of the result rows have been cached so
// return the next row from the buffer.
if (rowPtr < rowData.size()) {
currentRow = (Object[])rowData.get(rowPtr);
// This is a forward only result set so null out the buffer ref
// to allow for garbage collection (we can never access the row
// again once we have moved on).
rowData.set(rowPtr++, null);
pos++;
rowsInResult = pos;
} else {
pos = POS_AFTER_LAST;
currentRow = null;
}
} else {
// Need to read from server response
if (!statement.getTds().getNextRow()) {
statement.cacheResults();
pos = POS_AFTER_LAST;
currentRow = null;
} else {
currentRow = statement.getTds().getRowData();
pos++;
rowsInResult = pos;
}
}
// Check for server side errors
statement.getMessages().checkErrors();
return currentRow != null;
}
public boolean previous() throws SQLException {
checkOpen();
checkScrollable();
return false;
}
public boolean rowDeleted() throws SQLException {
checkOpen();
checkUpdateable();
return false;
}
public boolean rowInserted() throws SQLException {
checkOpen();
checkUpdateable();
return false;
}
public boolean rowUpdated() throws SQLException {
checkOpen();
checkUpdateable();
return false;
}
public boolean wasNull() throws SQLException {
checkOpen();
return wasNull;
}
public byte getByte(int columnIndex) throws SQLException {
return ((Integer) Support.convert(this, getColumn(columnIndex), java.sql.Types.TINYINT, null)).byteValue();
}
public double getDouble(int columnIndex) throws SQLException {
return ((Double) Support.convert(this, getColumn(columnIndex), java.sql.Types.DOUBLE, null)).doubleValue();
}
public float getFloat(int columnIndex) throws SQLException {
return ((Float) Support.convert(this, getColumn(columnIndex), java.sql.Types.REAL, null)).floatValue();
}
public int getInt(int columnIndex) throws SQLException {
return ((Integer) Support.convert(this, getColumn(columnIndex), java.sql.Types.INTEGER, null)).intValue();
}
public long getLong(int columnIndex) throws SQLException {
return ((Long) Support.convert(this, getColumn(columnIndex), java.sql.Types.BIGINT, null)).longValue();
}
public short getShort(int columnIndex) throws SQLException {
return ((Integer) Support.convert(this, getColumn(columnIndex), java.sql.Types.SMALLINT, null)).shortValue();
}
public void setFetchDirection(int direction) throws SQLException {
checkOpen();
switch (direction) {
case FETCH_UNKNOWN:
case FETCH_REVERSE:
if (this.resultSetType == ResultSet.TYPE_FORWARD_ONLY) {
throw new SQLException(Messages.get("error.resultset.fwdonly"), "24000");
}
// Fall through
case FETCH_FORWARD:
this.fetchDirection = direction;
break;
default:
throw new SQLException(
Messages.get("error.generic.badoption",
Integer.toString(direction),
"direction"),
"24000");
}
}
public void setFetchSize(int rows) throws SQLException {
checkOpen();
if (rows < 0 || (statement.getMaxRows() > 0 && rows > statement.getMaxRows())) {
throw new SQLException(
Messages.get("error.generic.badparam",
Integer.toString(rows),
"rows"),
"HY092");
}
if (rows == 0) {
rows = statement.getDefaultFetchSize();
}
this.fetchSize = rows;
}
public void updateNull(int columnIndex) throws SQLException {
setColValue(columnIndex, Types.NULL, null, 0);
}
public boolean absolute(int row) throws SQLException {
checkOpen();
checkScrollable();
return false;
}
public boolean getBoolean(int columnIndex) throws SQLException {
return ((Boolean) Support.convert(this, getColumn(columnIndex), JtdsStatement.BOOLEAN, null)).booleanValue();
}
public boolean relative(int row) throws SQLException {
checkOpen();
checkScrollable();
return false;
}
public byte[] getBytes(int columnIndex) throws SQLException {
checkOpen();
return (byte[]) Support.convert(this, getColumn(columnIndex), java.sql.Types.BINARY, getConnection().getCharset());
}
public void updateByte(int columnIndex, byte x) throws SQLException {
setColValue(columnIndex, Types.INTEGER, new Integer(x & 0xFF), 0);
}
public void updateDouble(int columnIndex, double x) throws SQLException {
setColValue(columnIndex, Types.DOUBLE, new Double(x), 0);
}
public void updateFloat(int columnIndex, float x) throws SQLException {
setColValue(columnIndex, Types.REAL, new Float(x), 0);
}
public void updateInt(int columnIndex, int x) throws SQLException {
setColValue(columnIndex, Types.INTEGER, new Integer(x), 0);
}
public void updateLong(int columnIndex, long x) throws SQLException {
setColValue(columnIndex, Types.BIGINT, new Long(x), 0);
}
public void updateShort(int columnIndex, short x) throws SQLException {
setColValue(columnIndex, Types.INTEGER, new Integer(x), 0);
}
public void updateBoolean(int columnIndex, boolean x) throws SQLException {
setColValue(columnIndex, Types.BIT, x ? Boolean.TRUE : Boolean.FALSE, 0);
}
public void updateBytes(int columnIndex, byte[] x) throws SQLException {
setColValue(columnIndex, Types.VARBINARY, x, (x != null)? x.length: 0);
}
public InputStream getAsciiStream(int columnIndex) throws SQLException {
Clob clob = getClob(columnIndex);
if (clob == null) {
return null;
}
return clob.getAsciiStream();
}
public InputStream getBinaryStream(int columnIndex) throws SQLException {
Blob blob = getBlob(columnIndex);
if (blob == null) {
return null;
}
return blob.getBinaryStream();
}
public InputStream getUnicodeStream(int columnIndex) throws SQLException {
ClobImpl clob = (ClobImpl) getClob(columnIndex);
if (clob == null) {
return null;
}
return clob.getBlobBuffer().getUnicodeStream();
}
public void updateAsciiStream(int columnIndex, InputStream inputStream, int length)
throws SQLException {
if (inputStream == null || length < 0) {
updateCharacterStream(columnIndex, null, 0);
} else {
try {
updateCharacterStream(columnIndex, new InputStreamReader(inputStream, "US-ASCII"), length);
} catch (UnsupportedEncodingException e) {
// Should never happen!
}
}
}
public void updateBinaryStream(int columnIndex, InputStream inputStream, int length)
throws SQLException {
if (inputStream == null || length < 0) {
updateBytes(columnIndex, null);
return;
}
setColValue(columnIndex, java.sql.Types.VARBINARY, inputStream, length);
}
public Reader getCharacterStream(int columnIndex) throws SQLException {
Clob clob = getClob(columnIndex);
if (clob == null) {
return null;
}
return clob.getCharacterStream();
}
public void updateCharacterStream(int columnIndex, Reader reader, int length)
throws SQLException {
if (reader == null || length < 0) {
updateString(columnIndex, null);
return;
}
setColValue(columnIndex, java.sql.Types.VARCHAR, reader, length);
}
public Object getObject(int columnIndex) throws SQLException {
Object value = getColumn(columnIndex);
// Don't return UniqueIdentifier objects as the user won't know how to
// handle them
if (value instanceof UniqueIdentifier) {
return value.toString();
}
// Don't return DateTime objects as the user won't know how to
// handle them
if (value instanceof DateTime) {
return ((DateTime) value).toObject();
}
// If the user requested String/byte[] instead of LOBs, do the conversion
if (!getConnection().getUseLOBs()) {
value = Support.convertLOB(value);
}
return value;
}
public void updateObject(int columnIndex, Object x) throws SQLException {
checkOpen();
int length = 0;
int jdbcType = Types.VARCHAR; // Use for NULL values
if (x != null) {
// Need to do some conversion and testing here
jdbcType = Support.getJdbcType(x);
if (x instanceof BigDecimal) {
int prec = getConnection().getMaxPrecision();
x = Support.normalizeBigDecimal((BigDecimal)x, prec);
} else if (x instanceof Blob) {
Blob blob = (Blob) x;
x = blob.getBinaryStream();
length = (int) blob.length();
} else if (x instanceof Clob) {
Clob clob = (Clob) x;
x = clob.getCharacterStream();
length = (int) clob.length();
} else if (x instanceof String) {
length = ((String)x).length();
} else if (x instanceof byte[]) {
length = ((byte[])x).length;
}
if (jdbcType == Types.JAVA_OBJECT) {
// Unsupported class of object
if (columnIndex < 1 || columnIndex > columnCount) {
throw new SQLException(Messages.get("error.resultset.colindex",
Integer.toString(columnIndex)),
"07009");
}
ColInfo ci = columns[columnIndex-1];
throw new SQLException(
Messages.get("error.convert.badtypes",
x.getClass().getName(),
Support.getJdbcTypeName(ci.jdbcType)), "22005");
}
}
setColValue(columnIndex, jdbcType, x, length);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -