Method from com.mysql.jdbc.ResultSetImpl Detail: |
public boolean absolute(int row) throws SQLException {
checkClosed();
boolean b;
if (this.rowData.size() == 0) {
b = false;
} else {
if (row == 0) {
throw SQLError.createSQLException(
Messages
.getString("ResultSet.Cannot_absolute_position_to_row_0_110"), //$NON-NLS-1$
SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
}
if (this.onInsertRow) {
this.onInsertRow = false;
}
if (this.doingUpdates) {
this.doingUpdates = false;
}
if (this.thisRow != null) {
this.thisRow.closeOpenStreams();
}
if (row == 1) {
b = first();
} else if (row == -1) {
b = last();
} else if (row > this.rowData.size()) {
afterLast();
b = false;
} else {
if (row < 0) {
// adjust to reflect after end of result set
int newRowPosition = this.rowData.size() + row + 1;
if (newRowPosition < = 0) {
beforeFirst();
b = false;
} else {
b = absolute(newRowPosition);
}
} else {
row--; // adjust for index difference
this.rowData.setCurrentRow(row);
this.thisRow = this.rowData.getAt(row);
b = true;
}
}
}
setRowPositionValidity();
return b;
}
JDBC 2.0
Move to an absolute row number in the result set.
If row is positive, moves to an absolute row with respect to the
beginning of the result set. The first row is row 1, the second is row 2,
etc.
If row is negative, moves to an absolute row position with respect to the
end of result set. For example, calling absolute(-1) positions the cursor
on the last row, absolute(-2) indicates the next-to-last row, etc.
An attempt to position the cursor beyond the first/last row in the result
set, leaves the cursor before/after the first/last row, respectively.
Note: Calling absolute(1) is the same as calling first(). Calling
absolute(-1) is the same as calling last().
|
public void afterLast() throws SQLException {
checkClosed();
if (this.onInsertRow) {
this.onInsertRow = false;
}
if (this.doingUpdates) {
this.doingUpdates = false;
}
if (this.thisRow != null) {
this.thisRow.closeOpenStreams();
}
if (this.rowData.size() != 0) {
this.rowData.afterLast();
this.thisRow = null;
}
setRowPositionValidity();
}
JDBC 2.0
Moves to the end of the result set, just after the last row. Has no
effect if the result set contains no rows.
|
public static boolean arraysEqual(byte[] left,
byte[] right) {
if (left == null) {
return right == null;
}
if (right == null) {
return false;
}
if (left.length != right.length) {
return false;
}
for (int i = 0; i < left.length; i++) {
if (left[i] != right[i]) {
return false;
}
}
return true;
}
|
public void beforeFirst() throws SQLException {
checkClosed();
if (this.onInsertRow) {
this.onInsertRow = false;
}
if (this.doingUpdates) {
this.doingUpdates = false;
}
if (this.rowData.size() == 0) {
return;
}
if (this.thisRow != null) {
this.thisRow.closeOpenStreams();
}
this.rowData.beforeFirst();
this.thisRow = null;
setRowPositionValidity();
}
JDBC 2.0
Moves to the front of the result set, just before the first row. Has no
effect if the result set contains no rows.
|
public void buildIndexMapping() throws SQLException {
int numFields = this.fields.length;
this.columnLabelToIndex = new TreeMap(String.CASE_INSENSITIVE_ORDER);
this.fullColumnNameToIndex = new TreeMap(String.CASE_INSENSITIVE_ORDER);
this.columnNameToIndex = new TreeMap(String.CASE_INSENSITIVE_ORDER);
// We do this in reverse order, so that the 'first' column
// with a given name ends up as the final mapping in the
// hashtable...
//
// Quoting the JDBC Spec:
//
// "Column names used as input to getter
// methods are case insensitive. When a getter method is called with a
// column
// name and several columns have the same name, the value of the first
// matching column will be returned. "
//
for (int i = numFields - 1; i >= 0; i--) {
Integer index = Constants.integerValueOf(i);
String columnName = this.fields[i].getOriginalName();
String columnLabel = this.fields[i].getName();
String fullColumnName = this.fields[i].getFullName();
if (columnLabel != null) {
this.columnLabelToIndex.put(columnLabel, index);
}
if (fullColumnName != null) {
this.fullColumnNameToIndex.put(fullColumnName, index);
}
if (columnName != null) {
this.columnNameToIndex.put(columnName, index);
}
}
// set the flag to prevent rebuilding...
this.hasBuiltIndexMapping = true;
}
Builds a hash between column names and their indices for fast retrieval. |
public void cancelRowUpdates() throws SQLException {
throw new NotUpdatable();
}
JDBC 2.0 The cancelRowUpdates() method may be called after calling an
updateXXX() method(s) and before calling updateRow() to rollback the
updates made to a row. If no updates have been made or updateRow() has
already been called, then this method has no effect. |
protected final void checkClosed() throws SQLException {
if (this.isClosed) {
throw SQLError.createSQLException(
Messages
.getString("ResultSet.Operation_not_allowed_after_ResultSet_closed_144"), //$NON-NLS-1$
SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
}
}
Ensures that the result set is not closed |
protected final void checkColumnBounds(int columnIndex) throws SQLException {
if ((columnIndex < 1)) {
throw SQLError.createSQLException(Messages.getString(
"ResultSet.Column_Index_out_of_range_low", new Object[] {
Constants.integerValueOf(columnIndex),
Constants.integerValueOf(this.fields.length) }),
SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
} else if ((columnIndex > this.fields.length)) {
throw SQLError.createSQLException(Messages.getString(
"ResultSet.Column_Index_out_of_range_high", new Object[] {
Constants.integerValueOf(columnIndex),
Constants.integerValueOf(this.fields.length) }),
SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
}
if (this.profileSql || this.useUsageAdvisor) {
this.columnUsed[columnIndex - 1] = true;
}
}
Checks if columnIndex is within the number of columns in this result set. |
protected void checkRowPos() throws SQLException {
checkClosed();
if (!this.onValidRow) {
throw SQLError.createSQLException(this.invalidRowReason,
SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
}
}
Ensures that the cursor is positioned on a valid row and that the result
set is not closed |
public void clearNextResult() {
this.nextResultSet = null;
}
We can't do this ourselves, otherwise the contract for
Statement.getMoreResults() won't work correctly. |
public void clearWarnings() throws SQLException {
this.warningChain = null;
}
After this call, getWarnings returns null until a new warning is reported
for this ResultSet |
public void close() throws SQLException {
realClose(true);
}
In some cases, it is desirable to immediately release a ResultSet
database and JDBC resources instead of waiting for this to happen when it
is automatically closed. The close method provides this immediate
release.
Note: A ResultSet is automatically closed by the Statement the
Statement that generated it when that Statement is closed, re-executed,
or is used to retrieve the next result from a sequence of multiple
results. A ResultSet is also automatically closed when it is garbage
collected.
|
protected static BigInteger convertLongToUlong(long longVal) {
byte[] asBytes = new byte[8];
asBytes[7] = (byte) (longVal & 0xff);
asBytes[6] = (byte) (longVal > > > 8);
asBytes[5] = (byte) (longVal > > > 16);
asBytes[4] = (byte) (longVal > > > 24);
asBytes[3] = (byte) (longVal > > > 32);
asBytes[2] = (byte) (longVal > > > 40);
asBytes[1] = (byte) (longVal > > > 48);
asBytes[0] = (byte) (longVal > > > 56);
return new BigInteger(1, asBytes);
}
Converts the given value as a java long, to an 'unsigned' long, using the
java.math.BigInteger class. |
public ResultSetInternalMethods copy() throws SQLException {
ResultSetInternalMethods rs = ResultSetImpl.getInstance(this.catalog, this.fields, this.rowData,
this.connection, this.owningStatement, false); // note, doesn't work for updatable result sets
return rs;
}
|
public void deleteRow() throws SQLException {
throw new NotUpdatable();
}
JDBC 2.0 Delete the current row from the result set and the underlying
database. Cannot be called when on the insert row. |
protected synchronized Date fastDateCreate(Calendar cal,
int year,
int month,
int day) {
if (this.useLegacyDatetimeCode) {
return TimeUtil.fastDateCreate(year, month, day, cal);
}
if (cal == null) {
createCalendarIfNeeded();
cal = this.fastDateCal;
}
boolean useGmtMillis = this.connection.getUseGmtMillisForDatetimes();
return TimeUtil.fastDateCreate(useGmtMillis,
useGmtMillis ? getGmtCalendar() : cal,
cal, year, month, day);
}
|
protected synchronized Time fastTimeCreate(Calendar cal,
int hour,
int minute,
int second) throws SQLException {
if (!this.useLegacyDatetimeCode) {
return TimeUtil.fastTimeCreate(hour, minute, second, cal, getExceptionInterceptor());
}
if (cal == null) {
createCalendarIfNeeded();
cal = this.fastDateCal;
}
return TimeUtil.fastTimeCreate(cal, hour, minute, second, getExceptionInterceptor());
}
|
protected synchronized Timestamp fastTimestampCreate(Calendar cal,
int year,
int month,
int day,
int hour,
int minute,
int seconds,
int secondsPart) {
if (!this.useLegacyDatetimeCode) {
return TimeUtil.fastTimestampCreate(cal.getTimeZone(), year, month, day, hour,
minute, seconds, secondsPart);
}
if (cal == null) {
createCalendarIfNeeded();
cal = this.fastDateCal;
}
boolean useGmtMillis = this.connection.getUseGmtMillisForDatetimes();
return TimeUtil.fastTimestampCreate(useGmtMillis,
useGmtMillis ? getGmtCalendar() : null,
cal, year, month, day, hour,
minute, seconds, secondsPart);
}
|
public synchronized int findColumn(String columnName) throws SQLException {
Integer index;
checkClosed();
if (!this.hasBuiltIndexMapping) {
buildIndexMapping();
}
index = (Integer) this.columnToIndexCache.get(columnName);
if (index != null) {
return index.intValue() + 1;
}
index = (Integer) this.columnLabelToIndex.get(columnName);
if (index == null && this.useColumnNamesInFindColumn) {
index = (Integer) this.columnNameToIndex.get(columnName);
}
if (index == null) {
index = (Integer) this.fullColumnNameToIndex.get(columnName);
}
if (index != null) {
this.columnToIndexCache.put(columnName, index);
return index.intValue() + 1;
}
// Try this inefficient way, now
for (int i = 0; i < this.fields.length; i++) {
if (this.fields[i].getName().equalsIgnoreCase(columnName)) {
return i + 1;
} else if (this.fields[i].getFullName()
.equalsIgnoreCase(columnName)) {
return i + 1;
}
}
throw SQLError.createSQLException(Messages.getString("ResultSet.Column____112")
+ columnName
+ Messages.getString("ResultSet.___not_found._113"), //$NON-NLS-1$ //$NON-NLS-2$
SQLError.SQL_STATE_COLUMN_NOT_FOUND, getExceptionInterceptor());
}
|
public boolean first() throws SQLException {
checkClosed();
boolean b = true;
if (this.rowData.isEmpty()) {
b = false;
} else {
if (this.onInsertRow) {
this.onInsertRow = false;
}
if (this.doingUpdates) {
this.doingUpdates = false;
}
this.rowData.beforeFirst();
this.thisRow = this.rowData.next();
}
setRowPositionValidity();
return b;
}
|
public Array getArray(int i) throws SQLException {
checkColumnBounds(i);
throw SQLError.notImplemented();
}
JDBC 2.0 Get an array column. |
public Array getArray(String colName) throws SQLException {
return getArray(findColumn(colName));
}
JDBC 2.0 Get an array column. |
public InputStream getAsciiStream(int columnIndex) throws SQLException {
checkRowPos();
if (!this.isBinaryEncoded) {
return getBinaryStream(columnIndex);
}
return getNativeBinaryStream(columnIndex);
}
A column value can be retrieved as a stream of ASCII characters and then
read in chunks from the stream. This method is particulary suitable for
retrieving large LONGVARCHAR values. The JDBC driver will do any
necessary conversion from the database format into ASCII.
Note: All the data in the returned stream must be read prior to
getting the value of any other column. The next call to a get method
implicitly closes the stream. Also, a stream may return 0 for available()
whether there is data available or not.
|
public InputStream getAsciiStream(String columnName) throws SQLException {
return getAsciiStream(findColumn(columnName));
}
|
public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
if (!this.isBinaryEncoded) {
String stringVal = getString(columnIndex);
BigDecimal val;
if (stringVal != null) {
if (stringVal.length() == 0) {
val = new BigDecimal(
convertToZeroLiteralStringWithEmptyCheck());
return val;
}
try {
val = new BigDecimal(stringVal);
return val;
} catch (NumberFormatException ex) {
throw SQLError.createSQLException(Messages
.getString("ResultSet.Bad_format_for_BigDecimal",
new Object[] { stringVal,
Constants.integerValueOf(columnIndex) }),
SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
}
}
return null;
}
return getNativeBigDecimal(columnIndex);
}
JDBC 2.0 Get the value of a column in the current row as a
java.math.BigDecimal object. |
public BigDecimal getBigDecimal(String columnName) throws SQLException {
return getBigDecimal(findColumn(columnName));
}
JDBC 2.0 Get the value of a column in the current row as a
java.math.BigDecimal object. |
public BigDecimal getBigDecimal(int columnIndex,
int scale) throws SQLException {
if (!this.isBinaryEncoded) {
String stringVal = getString(columnIndex);
BigDecimal val;
if (stringVal != null) {
if (stringVal.length() == 0) {
val = new BigDecimal(
convertToZeroLiteralStringWithEmptyCheck());
try {
return val.setScale(scale);
} catch (ArithmeticException ex) {
try {
return val
.setScale(scale, BigDecimal.ROUND_HALF_UP);
} catch (ArithmeticException arEx) {
throw SQLError.createSQLException(
Messages
.getString("ResultSet.Bad_format_for_BigDecimal", //$NON-NLS-1$
new Object[] {stringVal, new Integer(columnIndex)}),
SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
}
}
}
try {
val = new BigDecimal(stringVal);
} catch (NumberFormatException ex) {
if (this.fields[columnIndex - 1].getMysqlType() == MysqlDefs.FIELD_TYPE_BIT) {
long valueAsLong = getNumericRepresentationOfSQLBitType(columnIndex);
val = new BigDecimal(valueAsLong);
} else {
throw SQLError.createSQLException(Messages
.getString("ResultSet.Bad_format_for_BigDecimal",
new Object[] { Constants.integerValueOf(columnIndex),
stringVal }),
SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
}
}
try {
return val.setScale(scale);
} catch (ArithmeticException ex) {
try {
return val.setScale(scale, BigDecimal.ROUND_HALF_UP);
} catch (ArithmeticException arithEx) {
throw SQLError.createSQLException(Messages.getString(
"ResultSet.Bad_format_for_BigDecimal",
new Object[] { Constants.integerValueOf(columnIndex),
stringVal }),
SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
}
}
}
return null;
}
return getNativeBigDecimal(columnIndex, scale);
} Deprecated!
Get the value of a column in the current row as a java.math.BigDecimal
object |
public BigDecimal getBigDecimal(String columnName,
int scale) throws SQLException {
return getBigDecimal(findColumn(columnName), scale);
} Deprecated!
|
public InputStream getBinaryStream(int columnIndex) throws SQLException {
checkRowPos();
if (!this.isBinaryEncoded) {
checkColumnBounds(columnIndex);
int columnIndexMinusOne = columnIndex - 1;
if (this.thisRow.isNull(columnIndexMinusOne)) {
this.wasNullFlag = true;
return null;
}
this.wasNullFlag = false;
return this.thisRow.getBinaryInputStream(columnIndexMinusOne);
}
return getNativeBinaryStream(columnIndex);
}
A column value can also be retrieved as a binary stream. This method is
suitable for retrieving LONGVARBINARY values. |
public InputStream getBinaryStream(String columnName) throws SQLException {
return getBinaryStream(findColumn(columnName));
}
|
public Blob getBlob(int columnIndex) throws SQLException {
if (!this.isBinaryEncoded) {
checkRowPos();
checkColumnBounds(columnIndex);
int columnIndexMinusOne = columnIndex - 1;
if (this.thisRow.isNull(columnIndexMinusOne)) {
this.wasNullFlag = true;
} else {
this.wasNullFlag = false;
}
if (this.wasNullFlag) {
return null;
}
if (!this.connection.getEmulateLocators()) {
return new Blob(this.thisRow.getColumnValue(columnIndexMinusOne), getExceptionInterceptor());
}
return new BlobFromLocator(this, columnIndex, getExceptionInterceptor());
}
return getNativeBlob(columnIndex);
}
JDBC 2.0 Get a BLOB column. |
public Blob getBlob(String colName) throws SQLException {
return getBlob(findColumn(colName));
}
JDBC 2.0 Get a BLOB column. |
public boolean getBoolean(int columnIndex) throws SQLException {
checkColumnBounds(columnIndex);
//
// MySQL 5.0 and newer have an actual BIT type,
// so we need to check for that here...
//
int columnIndexMinusOne = columnIndex - 1;
Field field = this.fields[columnIndexMinusOne];
if (field.getMysqlType() == MysqlDefs.FIELD_TYPE_BIT) {
return byteArrayToBoolean(columnIndexMinusOne);
}
this.wasNullFlag = false;
int sqlType = field.getSQLType();
switch (sqlType) {
case Types.BOOLEAN:
if (field.getMysqlType() == -1) { // from dbmd
String stringVal = getString(columnIndex);
return getBooleanFromString(stringVal, columnIndex);
}
long boolVal = getLong(columnIndex, false);
return (boolVal == -1 || boolVal > 0);
case Types.BIT:
case Types.TINYINT:
case Types.SMALLINT:
case Types.INTEGER:
case Types.BIGINT:
case Types.DECIMAL:
case Types.NUMERIC:
case Types.REAL:
case Types.FLOAT:
case Types.DOUBLE:
boolVal = getLong(columnIndex, false);
return (boolVal == -1 || boolVal > 0);
default:
if (this.connection.getPedantic()) {
// Table B-6 from JDBC spec
switch (sqlType) {
case Types.BINARY:
case Types.VARBINARY:
case Types.LONGVARBINARY:
case Types.DATE:
case Types.TIME:
case Types.TIMESTAMP:
case Types.CLOB:
case Types.BLOB:
case Types.ARRAY:
case Types.REF:
case Types.DATALINK:
case Types.STRUCT:
case Types.JAVA_OBJECT:
throw SQLError.createSQLException("Required type conversion not allowed",
SQLError.SQL_STATE_INVALID_CHARACTER_VALUE_FOR_CAST, getExceptionInterceptor());
}
}
if (sqlType == Types.BINARY ||
sqlType == Types.VARBINARY ||
sqlType == Types.LONGVARBINARY ||
sqlType == Types.BLOB) {
return byteArrayToBoolean(columnIndexMinusOne);
}
if (this.useUsageAdvisor) {
issueConversionViaParsingWarning("getBoolean()", columnIndex,
this.thisRow.getColumnValue(columnIndexMinusOne), this.fields[columnIndex],
new int[] {
MysqlDefs.FIELD_TYPE_BIT,
MysqlDefs.FIELD_TYPE_DOUBLE,
MysqlDefs.FIELD_TYPE_TINY,
MysqlDefs.FIELD_TYPE_SHORT,
MysqlDefs.FIELD_TYPE_LONG,
MysqlDefs.FIELD_TYPE_LONGLONG,
MysqlDefs.FIELD_TYPE_FLOAT });
}
String stringVal = getString(columnIndex);
return getBooleanFromString(stringVal, columnIndex);
}
}
Get the value of a column in the current row as a Java boolean |
public boolean getBoolean(String columnName) throws SQLException {
return getBoolean(findColumn(columnName));
}
|
public byte getByte(int columnIndex) throws SQLException {
if (!this.isBinaryEncoded) {
String stringVal = getString(columnIndex);
if (this.wasNullFlag || (stringVal == null)) {
return 0;
}
return getByteFromString(stringVal, columnIndex);
}
return getNativeByte(columnIndex);
}
Get the value of a column in the current row as a Java byte. |
public byte getByte(String columnName) throws SQLException {
return getByte(findColumn(columnName));
}
|
public byte[] getBytes(int columnIndex) throws SQLException {
return getBytes(columnIndex, false);
}
Get the value of a column in the current row as a Java byte array.
Be warned If the blob is huge, then you may run out of memory.
|
public byte[] getBytes(String columnName) throws SQLException {
return getBytes(findColumn(columnName));
}
|
protected byte[] getBytes(int columnIndex,
boolean noConversion) throws SQLException {
if (!this.isBinaryEncoded) {
checkRowPos();
checkColumnBounds(columnIndex);
int columnIndexMinusOne = columnIndex - 1;
if (this.thisRow.isNull(columnIndexMinusOne)) {
this.wasNullFlag = true;
} else {
this.wasNullFlag = false;
}
if (this.wasNullFlag) {
return null;
}
return this.thisRow.getColumnValue(columnIndexMinusOne);
}
return getNativeBytes(columnIndex, noConversion);
}
|
public int getBytesSize() throws SQLException {
RowData localRowData = this.rowData;
checkClosed();
if (localRowData instanceof RowDataStatic) {
int bytesSize = 0;
int numRows = localRowData.size();
for (int i = 0; i < numRows; i++) {
bytesSize += localRowData.getAt(i).getBytesSize();
}
return bytesSize;
}
return -1;
}
|
protected Calendar getCalendarInstanceForSessionOrNew() {
if (this.connection != null) {
return this.connection.getCalendarInstanceForSessionOrNew();
} else {
// punt, no connection around
return new GregorianCalendar();
}
}
Optimization to only use one calendar per-session, or calculate it for
each call, depending on user configuration |
public Reader getCharacterStream(int columnIndex) throws SQLException {
if (!this.isBinaryEncoded) {
checkColumnBounds(columnIndex);
int columnIndexMinusOne = columnIndex - 1;
if (this.thisRow.isNull(columnIndexMinusOne)) {
this.wasNullFlag = true;
return null;
}
this.wasNullFlag = false;
return this.thisRow.getReader(columnIndexMinusOne);
}
return getNativeCharacterStream(columnIndex);
}
|
public Reader getCharacterStream(String columnName) throws SQLException {
return getCharacterStream(findColumn(columnName));
}
|
public Clob getClob(int i) throws SQLException {
if (!this.isBinaryEncoded) {
String asString = getStringForClob(i);
if (asString == null) {
return null;
}
return new com.mysql.jdbc.Clob(asString, getExceptionInterceptor());
}
return getNativeClob(i);
}
JDBC 2.0 Get a CLOB column. |
public Clob getClob(String colName) throws SQLException {
return getClob(findColumn(colName));
}
JDBC 2.0 Get a CLOB column. |
public int getConcurrency() throws SQLException {
return (CONCUR_READ_ONLY);
}
JDBC 2.0 Return the concurrency of this result set. The concurrency used
is determined by the statement that created the result set. |
public String getCursorName() throws SQLException {
throw SQLError.createSQLException(Messages
.getString("ResultSet.Positioned_Update_not_supported"),
SQLError.SQL_STATE_DRIVER_NOT_CAPABLE, getExceptionInterceptor()); //$NON-NLS-1$
}
Get the name of the SQL cursor used by this ResultSet
In SQL, a result table is retrieved though a cursor that is named. The
current row of a result can be updated or deleted using a positioned
update/delete statement that references the cursor name.
JDBC supports this SQL feature by providing the name of the SQL cursor
used by a ResultSet. The current row of a ResulSet is also the current
row of this SQL cursor.
Note: If positioned update is not supported, a SQLException is
thrown.
|
public Date getDate(int columnIndex) throws SQLException {
return getDate(columnIndex, null);
}
Get the value of a column in the current row as a java.sql.Date object |
public Date getDate(String columnName) throws SQLException {
return getDate(findColumn(columnName));
}
|
public Date getDate(int columnIndex,
Calendar cal) throws SQLException {
if (this.isBinaryEncoded) {
return getNativeDate(columnIndex, cal);
}
if (!this.useFastDateParsing) {
String stringVal = getStringInternal(columnIndex, false);
if (stringVal == null) {
return null;
}
return getDateFromString(stringVal, columnIndex, cal);
}
checkColumnBounds(columnIndex);
int columnIndexMinusOne = columnIndex - 1;
if (this.thisRow.isNull(columnIndexMinusOne)) {
this.wasNullFlag = true;
return null;
}
this.wasNullFlag = false;
return this.thisRow.getDateFast(columnIndexMinusOne, this.connection, this, cal);
}
JDBC 2.0 Get the value of a column in the current row as a java.sql.Date
object. Use the calendar to construct an appropriate millisecond value
for the Date, if the underlying database doesn't store timezone
information. |
public Date getDate(String columnName,
Calendar cal) throws SQLException {
return getDate(findColumn(columnName), cal);
}
Get the value of a column in the current row as a java.sql.Date object.
Use the calendar to construct an appropriate millisecond value for the
Date, if the underlying database doesn't store timezone information. |
public double getDouble(int columnIndex) throws SQLException {
if (!this.isBinaryEncoded) {
return getDoubleInternal(columnIndex);
}
return getNativeDouble(columnIndex);
}
Get the value of a column in the current row as a Java double. |
public double getDouble(String columnName) throws SQLException {
return getDouble(findColumn(columnName));
}
|
protected double getDoubleInternal(int colIndex) throws SQLException {
return getDoubleInternal(getString(colIndex), colIndex);
}
Converts a string representation of a number to a double. Need a faster
way to do this. |
protected double getDoubleInternal(String stringVal,
int colIndex) throws SQLException {
try {
if ((stringVal == null)) {
return 0;
}
if (stringVal.length() == 0) {
return convertToZeroWithEmptyCheck();
}
double d = Double.parseDouble(stringVal);
if (this.useStrictFloatingPoint) {
// Fix endpoint rounding precision loss in MySQL server
if (d == 2.147483648E9) {
// Fix Odd end-point rounding on MySQL
d = 2.147483647E9;
} else if (d == 1.0000000036275E-15) {
// Fix odd end-point rounding on MySQL
d = 1.0E-15;
} else if (d == 9.999999869911E14) {
d = 9.99999999999999E14;
} else if (d == 1.4012984643248E-45) {
d = 1.4E-45;
} else if (d == 1.4013E-45) {
d = 1.4E-45;
} else if (d == 3.4028234663853E37) {
d = 3.4028235E37;
} else if (d == -2.14748E9) {
d = -2.147483648E9;
} else if (d == 3.40282E37) {
d = 3.4028235E37;
}
}
return d;
} catch (NumberFormatException e) {
if (this.fields[colIndex - 1].getMysqlType() == MysqlDefs.FIELD_TYPE_BIT) {
long valueAsLong = getNumericRepresentationOfSQLBitType(colIndex);
return valueAsLong;
}
throw SQLError.createSQLException(Messages.getString(
"ResultSet.Bad_format_for_number", new Object[] {
stringVal, Constants.integerValueOf(colIndex) }),
SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
}
}
Converts a string representation of a number to a double. Need a faster
way to do this. |
protected ExceptionInterceptor getExceptionInterceptor() {
return this.exceptionInterceptor;
}
|
public int getFetchDirection() throws SQLException {
return this.fetchDirection;
}
JDBC 2.0 Returns the fetch direction for this result set. |
public int getFetchSize() throws SQLException {
return this.fetchSize;
}
JDBC 2.0 Return the fetch size for this result set. |
public char getFirstCharOfQuery() {
return this.firstCharOfQuery;
}
Returns the first character of the query that this result set was created
from. |
public float getFloat(int columnIndex) throws SQLException {
if (!this.isBinaryEncoded) {
String val = null;
val = getString(columnIndex);
return getFloatFromString(val, columnIndex);
}
return getNativeFloat(columnIndex);
}
Get the value of a column in the current row as a Java float. |
public float getFloat(String columnName) throws SQLException {
return getFloat(findColumn(columnName));
}
|
protected Calendar getGmtCalendar() {
// Worst case we allocate this twice and the other gets GC'd,
// however prevents deadlock
if (this.gmtCalendar == null) {
this.gmtCalendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
}
return this.gmtCalendar;
}
|
protected static ResultSetImpl getInstance(long updateCount,
long updateID,
ConnectionImpl conn,
StatementImpl creatorStmt) throws SQLException {
if (!Util.isJdbc4()) {
return new ResultSetImpl(updateCount, updateID, conn, creatorStmt);
}
return (ResultSetImpl) Util.handleNewInstance(JDBC_4_RS_4_ARG_CTOR,
new Object[] { Constants.longValueOf(updateCount), Constants.longValueOf(updateID), conn,
creatorStmt}, conn.getExceptionInterceptor());
}
|
protected static ResultSetImpl getInstance(String catalog,
Field[] fields,
RowData tuples,
ConnectionImpl conn,
StatementImpl creatorStmt,
boolean isUpdatable) throws SQLException {
if (!Util.isJdbc4()) {
if (!isUpdatable) {
return new ResultSetImpl(catalog, fields, tuples, conn, creatorStmt);
}
return new UpdatableResultSet(catalog, fields, tuples, conn,
creatorStmt);
}
if (!isUpdatable) {
return (ResultSetImpl) Util
.handleNewInstance(JDBC_4_RS_6_ARG_CTOR, new Object[] {
catalog, fields, tuples, conn, creatorStmt }, conn.getExceptionInterceptor());
}
return (ResultSetImpl) Util.handleNewInstance(JDBC_4_UPD_RS_6_ARG_CTOR,
new Object[] { catalog, fields, tuples, conn, creatorStmt }, conn.getExceptionInterceptor());
}
Creates a result set instance that represents a query result -- We need
to provide factory-style methods so we can support both JDBC3 (and older)
and JDBC4 runtimes, otherwise the class verifier complains when it tries
to load JDBC4-only interface classes that are present in JDBC4 method
signatures. |
public int getInt(int columnIndex) throws SQLException {
checkRowPos();
if (!this.isBinaryEncoded) {
int columnIndexMinusOne = columnIndex - 1;
if (this.useFastIntParsing) {
checkColumnBounds(columnIndex);
if (this.thisRow.isNull(columnIndexMinusOne)) {
this.wasNullFlag = true;
} else {
this.wasNullFlag = false;
}
if (this.wasNullFlag) {
return 0;
}
if (this.thisRow.length(columnIndexMinusOne) == 0) {
return convertToZeroWithEmptyCheck();
}
boolean needsFullParse = this.thisRow
.isFloatingPointNumber(columnIndexMinusOne);
if (!needsFullParse) {
try {
return getIntWithOverflowCheck(columnIndexMinusOne);
} catch (NumberFormatException nfe) {
try {
return parseIntAsDouble(columnIndex, this.thisRow
.getString(columnIndexMinusOne,
this.fields[columnIndexMinusOne]
.getCharacterSet(),
this.connection));
} catch (NumberFormatException newNfe) {
// ignore, it's not a number
}
if (this.fields[columnIndexMinusOne].getMysqlType() == MysqlDefs.FIELD_TYPE_BIT) {
long valueAsLong = getNumericRepresentationOfSQLBitType(columnIndex);
if (this.connection
.getJdbcCompliantTruncationForReads()
&& (valueAsLong < Integer.MIN_VALUE || valueAsLong > Integer.MAX_VALUE)) {
throwRangeException(
String.valueOf(valueAsLong),
columnIndex, Types.INTEGER);
}
return (int) valueAsLong;
}
throw SQLError
.createSQLException(
Messages
.getString("ResultSet.Invalid_value_for_getInt()_-____74")
+ this.thisRow
.getString(
columnIndexMinusOne,
this.fields[columnIndexMinusOne]
.getCharacterSet(),
this.connection) //$NON-NLS-1$
+ "'",
SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
}
}
}
String val = null;
try {
val = getString(columnIndex);
if ((val != null)) {
if (val.length() == 0) {
return convertToZeroWithEmptyCheck();
}
if ((val.indexOf("e") == -1) && (val.indexOf("E") == -1)
&& (val.indexOf(".") == -1)) {
int intVal = Integer.parseInt(val);
checkForIntegerTruncation(columnIndexMinusOne, null, intVal);
return intVal;
}
// Convert floating point
int intVal = parseIntAsDouble(columnIndex, val);
checkForIntegerTruncation(columnIndex, null, intVal);
return intVal;
}
return 0;
} catch (NumberFormatException nfe) {
try {
return parseIntAsDouble(columnIndex, val);
} catch (NumberFormatException newNfe) {
; // ignore, it's not a number
}
if (this.fields[columnIndexMinusOne].getMysqlType() == MysqlDefs.FIELD_TYPE_BIT) {
long valueAsLong = getNumericRepresentationOfSQLBitType(columnIndex);
if (this.jdbcCompliantTruncationForReads
&& (valueAsLong < Integer.MIN_VALUE || valueAsLong > Integer.MAX_VALUE)) {
throwRangeException(String.valueOf(valueAsLong),
columnIndex, Types.INTEGER);
}
return (int) valueAsLong;
}
throw SQLError
.createSQLException(
Messages
.getString("ResultSet.Invalid_value_for_getInt()_-____74")
+ val //$NON-NLS-1$
+ "'",
SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
}
}
return getNativeInt(columnIndex);
}
Get the value of a column in the current row as a Java int. |
public int getInt(String columnName) throws SQLException {
return getInt(findColumn(columnName));
}
|
public long getLong(int columnIndex) throws SQLException {
return getLong(columnIndex, true);
}
Get the value of a column in the current row as a Java long. |
public long getLong(String columnName) throws SQLException {
return getLong(findColumn(columnName));
}
|
public ResultSetMetaData getMetaData() throws SQLException {
checkClosed();
return new com.mysql.jdbc.ResultSetMetaData(this.fields,
this.connection.getUseOldAliasMetadataBehavior(), getExceptionInterceptor());
}
The numbers, types and properties of a ResultSet's columns are provided
by the getMetaData method |
protected Array getNativeArray(int i) throws SQLException {
throw SQLError.notImplemented();
}
JDBC 2.0 Get an array column. |
protected InputStream getNativeAsciiStream(int columnIndex) throws SQLException {
checkRowPos();
return getNativeBinaryStream(columnIndex);
}
A column value can be retrieved as a stream of ASCII characters and then
read in chunks from the stream. This method is particulary suitable for
retrieving large LONGVARCHAR values. The JDBC driver will do any
necessary conversion from the database format into ASCII.
Note: All the data in the returned stream must be read prior to
getting the value of any other column. The next call to a get method
implicitly closes the stream. Also, a stream may return 0 for available()
whether there is data available or not.
|
protected BigDecimal getNativeBigDecimal(int columnIndex) throws SQLException {
checkColumnBounds(columnIndex);
int scale = this.fields[columnIndex - 1].getDecimals();
return getNativeBigDecimal(columnIndex, scale);
}
JDBC 2.0 Get the value of a column in the current row as a
java.math.BigDecimal object. |
protected BigDecimal getNativeBigDecimal(int columnIndex,
int scale) throws SQLException {
checkColumnBounds(columnIndex);
String stringVal = null;
Field f = this.fields[columnIndex - 1];
Object value = this.thisRow.getColumnValue(columnIndex - 1);
if (value == null) {
this.wasNullFlag = true;
return null;
}
this.wasNullFlag = false;
switch (f.getSQLType()) {
case Types.DECIMAL:
case Types.NUMERIC:
stringVal = StringUtils
.toAsciiString((byte[]) value);
break;
default:
stringVal = getNativeString(columnIndex);
}
return getBigDecimalFromString(stringVal, columnIndex, scale);
}
Get the value of a column in the current row as a java.math.BigDecimal
object |
protected InputStream getNativeBinaryStream(int columnIndex) throws SQLException {
checkRowPos();
int columnIndexMinusOne = columnIndex - 1;
if (this.thisRow.isNull(columnIndexMinusOne)) {
this.wasNullFlag = true;
return null;
}
this.wasNullFlag = false;
switch (this.fields[columnIndexMinusOne].getSQLType()) {
case Types.BIT:
case Types.BINARY:
case Types.VARBINARY:
case Types.BLOB:
case Types.LONGVARBINARY:
return this.thisRow.getBinaryInputStream(columnIndexMinusOne);
}
byte[] b = getNativeBytes(columnIndex, false);
if (b != null) {
return new ByteArrayInputStream(b);
}
return null;
}
A column value can also be retrieved as a binary stream. This method is
suitable for retrieving LONGVARBINARY values. |
protected Blob getNativeBlob(int columnIndex) throws SQLException {
checkRowPos();
checkColumnBounds(columnIndex);
Object value = this.thisRow.getColumnValue(columnIndex - 1);
if (value == null) {
this.wasNullFlag = true;
} else {
this.wasNullFlag = false;
}
if (this.wasNullFlag) {
return null;
}
int mysqlType = this.fields[columnIndex - 1].getMysqlType();
byte[] dataAsBytes = null;
switch (mysqlType) {
case MysqlDefs.FIELD_TYPE_TINY_BLOB:
case MysqlDefs.FIELD_TYPE_MEDIUM_BLOB:
case MysqlDefs.FIELD_TYPE_LONG_BLOB:
case MysqlDefs.FIELD_TYPE_BLOB:
dataAsBytes = (byte[]) value;
break;
default:
dataAsBytes = getNativeBytes(columnIndex, false);
}
if (!this.connection.getEmulateLocators()) {
return new Blob(dataAsBytes, getExceptionInterceptor());
}
return new BlobFromLocator(this, columnIndex, getExceptionInterceptor());
}
JDBC 2.0 Get a BLOB column. |
protected byte getNativeByte(int columnIndex) throws SQLException {
return getNativeByte(columnIndex, true);
}
Get the value of a column in the current row as a Java byte. |
protected byte getNativeByte(int columnIndex,
boolean overflowCheck) throws SQLException {
checkRowPos();
checkColumnBounds(columnIndex);
Object value = this.thisRow.getColumnValue(columnIndex - 1);
if (value == null) {
this.wasNullFlag = true;
return 0;
}
if (value == null) {
this.wasNullFlag = true;
} else {
this.wasNullFlag = false;
}
if (this.wasNullFlag) {
return 0;
}
columnIndex--;
Field field = this.fields[columnIndex];
switch (field.getMysqlType()) {
case MysqlDefs.FIELD_TYPE_BIT:
long valueAsLong = getNumericRepresentationOfSQLBitType(columnIndex + 1);
if (overflowCheck && this.jdbcCompliantTruncationForReads &&
(valueAsLong < Byte.MIN_VALUE
|| valueAsLong > Byte.MAX_VALUE)) {
throwRangeException(String.valueOf(valueAsLong), columnIndex + 1,
Types.TINYINT);
}
return (byte)valueAsLong;
case MysqlDefs.FIELD_TYPE_TINY:
byte valueAsByte = ((byte[]) value)[0];
if (!field.isUnsigned()) {
return valueAsByte;
}
short valueAsShort = (valueAsByte >= 0) ?
valueAsByte : (short)(valueAsByte + (short)256);
if (overflowCheck && this.jdbcCompliantTruncationForReads) {
if (valueAsShort > Byte.MAX_VALUE) {
throwRangeException(String.valueOf(valueAsShort),
columnIndex + 1, Types.TINYINT);
}
}
return (byte)valueAsShort;
case MysqlDefs.FIELD_TYPE_SHORT:
case MysqlDefs.FIELD_TYPE_YEAR:
valueAsShort = getNativeShort(columnIndex + 1);
if (overflowCheck && this.jdbcCompliantTruncationForReads) {
if (valueAsShort < Byte.MIN_VALUE
|| valueAsShort > Byte.MAX_VALUE) {
throwRangeException(String.valueOf(valueAsShort),
columnIndex + 1, Types.TINYINT);
}
}
return (byte) valueAsShort;
case MysqlDefs.FIELD_TYPE_INT24:
case MysqlDefs.FIELD_TYPE_LONG:
int valueAsInt = getNativeInt(columnIndex + 1, false);
if (overflowCheck && this.jdbcCompliantTruncationForReads) {
if (valueAsInt < Byte.MIN_VALUE || valueAsInt > Byte.MAX_VALUE) {
throwRangeException(String.valueOf(valueAsInt),
columnIndex + 1, Types.TINYINT);
}
}
return (byte) valueAsInt;
case MysqlDefs.FIELD_TYPE_FLOAT:
float valueAsFloat = getNativeFloat(columnIndex + 1);
if (overflowCheck && this.jdbcCompliantTruncationForReads) {
if (valueAsFloat < Byte.MIN_VALUE
|| valueAsFloat > Byte.MAX_VALUE) {
throwRangeException(String.valueOf(valueAsFloat),
columnIndex + 1, Types.TINYINT);
}
}
return (byte) valueAsFloat;
case MysqlDefs.FIELD_TYPE_DOUBLE:
double valueAsDouble = getNativeDouble(columnIndex + 1);
if (overflowCheck && this.jdbcCompliantTruncationForReads) {
if (valueAsDouble < Byte.MIN_VALUE
|| valueAsDouble > Byte.MAX_VALUE) {
throwRangeException(String.valueOf(valueAsDouble),
columnIndex + 1, Types.TINYINT);
}
}
return (byte) valueAsDouble;
case MysqlDefs.FIELD_TYPE_LONGLONG:
valueAsLong = getNativeLong(columnIndex + 1, false, true);
if (overflowCheck && this.jdbcCompliantTruncationForReads) {
if (valueAsLong < Byte.MIN_VALUE
|| valueAsLong > Byte.MAX_VALUE) {
throwRangeException(String.valueOf(valueAsLong),
columnIndex + 1, Types.TINYINT);
}
}
return (byte) valueAsLong;
default:
if (this.useUsageAdvisor) {
issueConversionViaParsingWarning("getByte()", columnIndex,
this.thisRow.getColumnValue(columnIndex - 1), this.fields[columnIndex],
new int[] { MysqlDefs.FIELD_TYPE_DOUBLE,
MysqlDefs.FIELD_TYPE_TINY,
MysqlDefs.FIELD_TYPE_SHORT,
MysqlDefs.FIELD_TYPE_LONG,
MysqlDefs.FIELD_TYPE_LONGLONG,
MysqlDefs.FIELD_TYPE_FLOAT });
}
return getByteFromString(getNativeString(columnIndex + 1),
columnIndex + 1);
}
}
|
protected byte[] getNativeBytes(int columnIndex,
boolean noConversion) throws SQLException {
checkRowPos();
checkColumnBounds(columnIndex);
Object value = this.thisRow.getColumnValue(columnIndex - 1);
if (value == null) {
this.wasNullFlag = true;
} else {
this.wasNullFlag = false;
}
if (this.wasNullFlag) {
return null;
}
Field field = this.fields[columnIndex - 1];
int mysqlType = field.getMysqlType();
// Workaround for emulated locators in servers > 4.1,
// as server returns SUBSTRING(blob) as STRING type...
if (noConversion) {
mysqlType = MysqlDefs.FIELD_TYPE_BLOB;
}
switch (mysqlType) {
case MysqlDefs.FIELD_TYPE_TINY_BLOB:
case MysqlDefs.FIELD_TYPE_MEDIUM_BLOB:
case MysqlDefs.FIELD_TYPE_LONG_BLOB:
case MysqlDefs.FIELD_TYPE_BLOB:
case MysqlDefs.FIELD_TYPE_BIT:
return (byte[]) value;
case MysqlDefs.FIELD_TYPE_STRING:
case MysqlDefs.FIELD_TYPE_VARCHAR:
case MysqlDefs.FIELD_TYPE_VAR_STRING:
if (value instanceof byte[]) {
return (byte[]) value;
}
// fallthrough
default:
int sqlType = field.getSQLType();
if (sqlType == Types.VARBINARY || sqlType == Types.BINARY) {
return (byte[]) value;
}
return getBytesFromString(getNativeString(columnIndex), columnIndex);
}
}
Get the value of a column in the current row as a Java byte array.
Be warned If the blob is huge, then you may run out of memory.
|
protected Reader getNativeCharacterStream(int columnIndex) throws SQLException {
int columnIndexMinusOne = columnIndex - 1;
switch (this.fields[columnIndexMinusOne].getSQLType()) {
case Types.CHAR:
case Types.VARCHAR:
case Types.LONGVARCHAR:
case Types.CLOB:
if (this.thisRow.isNull(columnIndexMinusOne)) {
this.wasNullFlag = true;
return null;
}
this.wasNullFlag = false;
return this.thisRow.getReader(columnIndexMinusOne);
}
String asString = null;
asString = getStringForClob(columnIndex);
if (asString == null) {
return null;
}
return getCharacterStreamFromString(asString, columnIndex);
}
|
protected Clob getNativeClob(int columnIndex) throws SQLException {
String stringVal = getStringForClob(columnIndex);
if (stringVal == null) {
return null;
}
return getClobFromString(stringVal, columnIndex);
}
JDBC 2.0 Get a CLOB column. |
protected Date getNativeDate(int columnIndex) throws SQLException {
return getNativeDate(columnIndex, null);
}
Get the value of a column in the current row as a java.sql.Date object |
protected Date getNativeDate(int columnIndex,
Calendar cal) throws SQLException {
checkRowPos();
checkColumnBounds(columnIndex);
int columnIndexMinusOne = columnIndex - 1;
int mysqlType = this.fields[columnIndexMinusOne].getMysqlType();
java.sql.Date dateToReturn = null;
if (mysqlType == MysqlDefs.FIELD_TYPE_DATE) {
dateToReturn = this.thisRow.getNativeDate(columnIndexMinusOne,
this.connection, this, cal);
} else {
TimeZone tz = (cal != null) ? cal.getTimeZone()
: this.getDefaultTimeZone();
boolean rollForward = (tz != null && !tz.equals(this.getDefaultTimeZone()));
dateToReturn = (Date) this.thisRow.getNativeDateTimeValue(columnIndexMinusOne,
null, Types.DATE, mysqlType, tz, rollForward, this.connection,
this);
}
//
// normally, we allow ResultSetImpl methods to check for null first,
// but with DATETIME values we have this wacky need to support
// 0000-00-00 00:00:00 - > NULL, so we have to defer
// to the RowHolder implementation, and check the return value.
//
if (dateToReturn == null) {
this.wasNullFlag = true;
return null;
}
this.wasNullFlag = false;
return dateToReturn;
}
JDBC 2.0 Get the value of a column in the current row as a java.sql.Date
object. Use the calendar to construct an appropriate millisecond value
for the Date, if the underlying database doesn't store timezone
information. |
Date getNativeDateViaParseConversion(int columnIndex) throws SQLException {
if (this.useUsageAdvisor) {
issueConversionViaParsingWarning("getDate()", columnIndex,
this.thisRow.getColumnValue(columnIndex - 1), this.fields[columnIndex - 1],
new int[] { MysqlDefs.FIELD_TYPE_DATE });
}
String stringVal = getNativeString(columnIndex);
return getDateFromString(stringVal, columnIndex, null);
}
|
protected double getNativeDouble(int columnIndex) throws SQLException {
checkRowPos();
checkColumnBounds(columnIndex);
columnIndex--; // / JDBC is 1-based
if (this.thisRow.isNull(columnIndex)) {
this.wasNullFlag = true;
return 0;
}
this.wasNullFlag = false;
Field f= this.fields[columnIndex];
switch (f.getMysqlType()) {
case MysqlDefs.FIELD_TYPE_DOUBLE:
return this.thisRow.getNativeDouble(columnIndex);
case MysqlDefs.FIELD_TYPE_TINY:
if (!f.isUnsigned()) {
return (double) getNativeByte(columnIndex + 1);
}
return (double) getNativeShort(columnIndex + 1);
case MysqlDefs.FIELD_TYPE_SHORT:
case MysqlDefs.FIELD_TYPE_YEAR:
if (!f.isUnsigned()) {
return (double) getNativeShort(columnIndex + 1);
}
return (double) getNativeInt(columnIndex + 1);
case MysqlDefs.FIELD_TYPE_INT24:
case MysqlDefs.FIELD_TYPE_LONG:
if (!f.isUnsigned()) {
return (double) getNativeInt(columnIndex + 1);
}
return (double) getNativeLong(columnIndex + 1);
case MysqlDefs.FIELD_TYPE_LONGLONG:
long valueAsLong = getNativeLong(columnIndex + 1);
if (!f.isUnsigned()) {
return (double) valueAsLong;
}
BigInteger asBigInt = convertLongToUlong(valueAsLong);
// TODO: Check for overflow
return asBigInt.doubleValue();
case MysqlDefs.FIELD_TYPE_FLOAT:
return (double) getNativeFloat(columnIndex + 1);
case MysqlDefs.FIELD_TYPE_BIT:
return getNumericRepresentationOfSQLBitType(columnIndex + 1);
default:
String stringVal = getNativeString(columnIndex + 1);
if (this.useUsageAdvisor) {
issueConversionViaParsingWarning("getDouble()", columnIndex,
stringVal, this.fields[columnIndex],
new int[] { MysqlDefs.FIELD_TYPE_DOUBLE,
MysqlDefs.FIELD_TYPE_TINY,
MysqlDefs.FIELD_TYPE_SHORT,
MysqlDefs.FIELD_TYPE_LONG,
MysqlDefs.FIELD_TYPE_LONGLONG,
MysqlDefs.FIELD_TYPE_FLOAT });
}
return getDoubleFromString(stringVal, columnIndex + 1);
}
}
Get the value of a column in the current row as a Java double. |
protected float getNativeFloat(int columnIndex) throws SQLException {
checkRowPos();
checkColumnBounds(columnIndex);
columnIndex--; // / JDBC is 1-based
if (this.thisRow.isNull(columnIndex)) {
this.wasNullFlag = true;
return 0;
}
this.wasNullFlag = false;
Field f = this.fields[columnIndex];
switch (f.getMysqlType()) {
case MysqlDefs.FIELD_TYPE_BIT:
long valueAsLong = getNumericRepresentationOfSQLBitType(columnIndex + 1);
return valueAsLong;
case MysqlDefs.FIELD_TYPE_DOUBLE:
// Only foolproof way to check for overflow
// Not efficient, but if you don't want to be inefficient, use the
// correct binding for the type!
Double valueAsDouble = new Double(getNativeDouble(columnIndex + 1));
float valueAsFloat = valueAsDouble.floatValue();
if (this.jdbcCompliantTruncationForReads &&
valueAsFloat == Float.NEGATIVE_INFINITY ||
valueAsFloat == Float.POSITIVE_INFINITY) {
throwRangeException(valueAsDouble.toString(),
columnIndex + 1, Types.FLOAT);
}
return (float) getNativeDouble(columnIndex + 1);
case MysqlDefs.FIELD_TYPE_TINY:
if (!f.isUnsigned()) {
return (float) getNativeByte(columnIndex + 1);
}
return (float) getNativeShort(columnIndex + 1);
case MysqlDefs.FIELD_TYPE_SHORT:
case MysqlDefs.FIELD_TYPE_YEAR:
if (!f.isUnsigned()) {
return (float) getNativeShort(columnIndex + 1);
}
return (float) getNativeInt(columnIndex + 1);
case MysqlDefs.FIELD_TYPE_INT24:
case MysqlDefs.FIELD_TYPE_LONG:
if (!f.isUnsigned()) {
return (float) getNativeInt(columnIndex + 1);
}
return (float) getNativeLong(columnIndex + 1);
case MysqlDefs.FIELD_TYPE_LONGLONG:
valueAsLong = getNativeLong(columnIndex + 1);
if (!f.isUnsigned()) {
return (float) valueAsLong;
}
BigInteger asBigInt = convertLongToUlong(valueAsLong);
// TODO: Check for overflow
return asBigInt.floatValue();
case MysqlDefs.FIELD_TYPE_FLOAT:
return this.thisRow.getNativeFloat(columnIndex);
default:
String stringVal = getNativeString(columnIndex + 1);
if (this.useUsageAdvisor) {
issueConversionViaParsingWarning("getFloat()", columnIndex,
stringVal, this.fields[columnIndex],
new int[] { MysqlDefs.FIELD_TYPE_DOUBLE,
MysqlDefs.FIELD_TYPE_TINY,
MysqlDefs.FIELD_TYPE_SHORT,
MysqlDefs.FIELD_TYPE_LONG,
MysqlDefs.FIELD_TYPE_LONGLONG,
MysqlDefs.FIELD_TYPE_FLOAT });
}
return getFloatFromString(stringVal, columnIndex + 1);
}
}
Get the value of a column in the current row as a Java float. |
protected int getNativeInt(int columnIndex) throws SQLException {
return getNativeInt(columnIndex, true);
}
Get the value of a column in the current row as a Java int. |
protected int getNativeInt(int columnIndex,
boolean overflowCheck) throws SQLException {
checkRowPos();
checkColumnBounds(columnIndex);
columnIndex--; // / JDBC is 1-based
if (this.thisRow.isNull(columnIndex)) {
this.wasNullFlag = true;
return 0;
}
this.wasNullFlag = false;
Field f = this.fields[columnIndex];
switch (f.getMysqlType()) {
case MysqlDefs.FIELD_TYPE_BIT:
long valueAsLong = getNumericRepresentationOfSQLBitType(columnIndex + 1);
if (overflowCheck && this.jdbcCompliantTruncationForReads &&
(valueAsLong < Integer.MIN_VALUE
|| valueAsLong > Integer.MAX_VALUE)) {
throwRangeException(String.valueOf(valueAsLong), columnIndex + 1,
Types.INTEGER);
}
return (short)valueAsLong;
case MysqlDefs.FIELD_TYPE_TINY:
byte tinyintVal = getNativeByte(columnIndex + 1, false);
if (!f.isUnsigned() || tinyintVal >= 0) {
return tinyintVal;
}
return tinyintVal + 256;
case MysqlDefs.FIELD_TYPE_SHORT:
case MysqlDefs.FIELD_TYPE_YEAR:
short asShort = getNativeShort(columnIndex + 1, false);
if (!f.isUnsigned() || asShort >= 0) {
return asShort;
}
return asShort + 65536;
case MysqlDefs.FIELD_TYPE_INT24:
case MysqlDefs.FIELD_TYPE_LONG:
int valueAsInt = this.thisRow.getNativeInt(columnIndex);
if (!f.isUnsigned()) {
return valueAsInt;
}
valueAsLong = (valueAsInt >= 0) ?
valueAsInt : valueAsInt + 4294967296L;
if (overflowCheck && this.jdbcCompliantTruncationForReads &&
valueAsLong > Integer.MAX_VALUE) {
throwRangeException(String.valueOf(valueAsLong),
columnIndex + 1, Types.INTEGER);
}
return (int)valueAsLong;
case MysqlDefs.FIELD_TYPE_LONGLONG:
valueAsLong = getNativeLong(columnIndex + 1, false, true);
if (overflowCheck && this.jdbcCompliantTruncationForReads) {
if (valueAsLong < Integer.MIN_VALUE
|| valueAsLong > Integer.MAX_VALUE) {
throwRangeException(String.valueOf(valueAsLong),
columnIndex + 1, Types.INTEGER);
}
}
return (int) valueAsLong;
case MysqlDefs.FIELD_TYPE_DOUBLE:
double valueAsDouble = getNativeDouble(columnIndex + 1);
if (overflowCheck && this.jdbcCompliantTruncationForReads) {
if (valueAsDouble < Integer.MIN_VALUE
|| valueAsDouble > Integer.MAX_VALUE) {
throwRangeException(String.valueOf(valueAsDouble),
columnIndex + 1, Types.INTEGER);
}
}
return (int) valueAsDouble;
case MysqlDefs.FIELD_TYPE_FLOAT:
valueAsDouble = getNativeFloat(columnIndex + 1);
if (overflowCheck && this.jdbcCompliantTruncationForReads) {
if (valueAsDouble < Integer.MIN_VALUE
|| valueAsDouble > Integer.MAX_VALUE) {
throwRangeException(String.valueOf(valueAsDouble),
columnIndex + 1, Types.INTEGER);
}
}
return (int) valueAsDouble;
default:
String stringVal = getNativeString(columnIndex + 1);
if (this.useUsageAdvisor) {
issueConversionViaParsingWarning("getInt()", columnIndex,
stringVal, this.fields[columnIndex],
new int[] { MysqlDefs.FIELD_TYPE_DOUBLE,
MysqlDefs.FIELD_TYPE_TINY,
MysqlDefs.FIELD_TYPE_SHORT,
MysqlDefs.FIELD_TYPE_LONG,
MysqlDefs.FIELD_TYPE_LONGLONG,
MysqlDefs.FIELD_TYPE_FLOAT });
}
return getIntFromString(stringVal, columnIndex + 1);
}
}
|
protected long getNativeLong(int columnIndex) throws SQLException {
return getNativeLong(columnIndex, true, true);
}
Get the value of a column in the current row as a Java long. |
protected long getNativeLong(int columnIndex,
boolean overflowCheck,
boolean expandUnsignedLong) throws SQLException {
checkRowPos();
checkColumnBounds(columnIndex);
columnIndex--; // / JDBC is 1-based
if (this.thisRow.isNull(columnIndex)) {
this.wasNullFlag = true;
return 0;
}
this.wasNullFlag = false;
Field f = this.fields[columnIndex];
switch (f.getMysqlType()) {
case MysqlDefs.FIELD_TYPE_BIT:
return getNumericRepresentationOfSQLBitType(columnIndex + 1);
case MysqlDefs.FIELD_TYPE_TINY:
if (!f.isUnsigned()) {
return getNativeByte(columnIndex + 1);
}
return getNativeInt(columnIndex + 1);
case MysqlDefs.FIELD_TYPE_SHORT:
if (!f.isUnsigned()) {
return getNativeShort(columnIndex + 1);
}
return getNativeInt(columnIndex + 1, false);
case MysqlDefs.FIELD_TYPE_YEAR:
return getNativeShort(columnIndex + 1);
case MysqlDefs.FIELD_TYPE_INT24:
case MysqlDefs.FIELD_TYPE_LONG:
int asInt = getNativeInt(columnIndex + 1, false);
if (!f.isUnsigned() || asInt >= 0) {
return asInt;
}
return asInt + 4294967296L;
case MysqlDefs.FIELD_TYPE_LONGLONG:
long valueAsLong = this.thisRow.getNativeLong(columnIndex);
if (!f.isUnsigned() || !expandUnsignedLong) {
return valueAsLong;
}
BigInteger asBigInt = convertLongToUlong(valueAsLong);
if (overflowCheck && this.jdbcCompliantTruncationForReads &&
((asBigInt.compareTo(new BigInteger(String.valueOf(Long.MAX_VALUE))) > 0 ) ||
(asBigInt.compareTo(new BigInteger(String.valueOf(Long.MIN_VALUE))) < 0))) {
throwRangeException(asBigInt.toString(),
columnIndex + 1, Types.BIGINT);
}
return getLongFromString(asBigInt.toString(), columnIndex);
case MysqlDefs.FIELD_TYPE_DOUBLE:
double valueAsDouble = getNativeDouble(columnIndex + 1);
if (overflowCheck && this.jdbcCompliantTruncationForReads) {
if (valueAsDouble < Long.MIN_VALUE
|| valueAsDouble > Long.MAX_VALUE) {
throwRangeException(String.valueOf(valueAsDouble),
columnIndex + 1, Types.BIGINT);
}
}
return (long) valueAsDouble;
case MysqlDefs.FIELD_TYPE_FLOAT:
valueAsDouble = getNativeFloat(columnIndex + 1);
if (overflowCheck && this.jdbcCompliantTruncationForReads) {
if (valueAsDouble < Long.MIN_VALUE
|| valueAsDouble > Long.MAX_VALUE) {
throwRangeException(String.valueOf(valueAsDouble),
columnIndex + 1, Types.BIGINT);
}
}
return (long) valueAsDouble;
default:
String stringVal = getNativeString(columnIndex + 1);
if (this.useUsageAdvisor) {
issueConversionViaParsingWarning("getLong()", columnIndex,
stringVal, this.fields[columnIndex],
new int[] { MysqlDefs.FIELD_TYPE_DOUBLE,
MysqlDefs.FIELD_TYPE_TINY,
MysqlDefs.FIELD_TYPE_SHORT,
MysqlDefs.FIELD_TYPE_LONG,
MysqlDefs.FIELD_TYPE_LONGLONG,
MysqlDefs.FIELD_TYPE_FLOAT });
}
return getLongFromString(stringVal, columnIndex + 1);
}
}
|
protected Ref getNativeRef(int i) throws SQLException {
throw SQLError.notImplemented();
}
JDBC 2.0 Get a REF(<structured-type>) column. |
protected short getNativeShort(int columnIndex) throws SQLException {
return getNativeShort(columnIndex, true);
}
Get the value of a column in the current row as a Java short. |
protected short getNativeShort(int columnIndex,
boolean overflowCheck) throws SQLException {
checkRowPos();
checkColumnBounds(columnIndex);
columnIndex--; // / JDBC is 1-based
if (this.thisRow.isNull(columnIndex)) {
this.wasNullFlag = true;
return 0;
}
this.wasNullFlag = false;
Field f = this.fields[columnIndex];
switch (f.getMysqlType()) {
case MysqlDefs.FIELD_TYPE_TINY:
byte tinyintVal = getNativeByte(columnIndex + 1, false);
if (!f.isUnsigned() || tinyintVal >= 0) {
return tinyintVal;
}
return (short)(tinyintVal + (short)256);
case MysqlDefs.FIELD_TYPE_SHORT:
case MysqlDefs.FIELD_TYPE_YEAR:
short asShort = this.thisRow.getNativeShort(columnIndex);
if (!f.isUnsigned()) {
return asShort;
}
int valueAsInt = asShort & 0xffff;
if (overflowCheck && this.jdbcCompliantTruncationForReads &&
valueAsInt > Short.MAX_VALUE) {
throwRangeException(String.valueOf(valueAsInt),
columnIndex + 1, Types.SMALLINT);
}
return (short)valueAsInt;
case MysqlDefs.FIELD_TYPE_INT24:
case MysqlDefs.FIELD_TYPE_LONG:
if (!f.isUnsigned()) {
valueAsInt = getNativeInt(columnIndex + 1, false);
if (overflowCheck && this.jdbcCompliantTruncationForReads &&
valueAsInt > Short.MAX_VALUE ||
valueAsInt < Short.MIN_VALUE) {
throwRangeException(String.valueOf(valueAsInt),
columnIndex + 1, Types.SMALLINT);
}
return (short)valueAsInt;
}
long valueAsLong = getNativeLong(columnIndex + 1, false, true);
if (overflowCheck && this.jdbcCompliantTruncationForReads &&
valueAsLong > Short.MAX_VALUE) {
throwRangeException(String.valueOf(valueAsLong),
columnIndex + 1, Types.SMALLINT);
}
return (short)valueAsLong;
case MysqlDefs.FIELD_TYPE_LONGLONG:
valueAsLong = getNativeLong(columnIndex + 1, false, false);
if (!f.isUnsigned()) {
if (overflowCheck && this.jdbcCompliantTruncationForReads) {
if (valueAsLong < Short.MIN_VALUE
|| valueAsLong > Short.MAX_VALUE) {
throwRangeException(String.valueOf(valueAsLong),
columnIndex + 1, Types.SMALLINT);
}
}
return (short) valueAsLong;
}
BigInteger asBigInt = convertLongToUlong(valueAsLong);
if (overflowCheck && this.jdbcCompliantTruncationForReads &&
((asBigInt.compareTo(new BigInteger(String.valueOf(Short.MAX_VALUE))) > 0 ) ||
(asBigInt.compareTo(new BigInteger(String.valueOf(Short.MIN_VALUE))) < 0))) {
throwRangeException(asBigInt.toString(),
columnIndex + 1, Types.SMALLINT);
}
return (short)getIntFromString(asBigInt.toString(), columnIndex + 1);
case MysqlDefs.FIELD_TYPE_DOUBLE:
double valueAsDouble = getNativeDouble(columnIndex + 1);
if (overflowCheck && this.jdbcCompliantTruncationForReads) {
if (valueAsDouble < Short.MIN_VALUE
|| valueAsDouble > Short.MAX_VALUE) {
throwRangeException(String.valueOf(valueAsDouble),
columnIndex + 1, Types.SMALLINT);
}
}
return (short) valueAsDouble;
case MysqlDefs.FIELD_TYPE_FLOAT:
float valueAsFloat = getNativeFloat(columnIndex + 1);
if (overflowCheck && this.jdbcCompliantTruncationForReads) {
if (valueAsFloat < Short.MIN_VALUE
|| valueAsFloat > Short.MAX_VALUE) {
throwRangeException(String.valueOf(valueAsFloat),
columnIndex + 1, Types.SMALLINT);
}
}
return (short) valueAsFloat;
default:
String stringVal = getNativeString(columnIndex + 1);
if (this.useUsageAdvisor) {
issueConversionViaParsingWarning("getShort()", columnIndex,
stringVal, this.fields[columnIndex],
new int[] { MysqlDefs.FIELD_TYPE_DOUBLE,
MysqlDefs.FIELD_TYPE_TINY,
MysqlDefs.FIELD_TYPE_SHORT,
MysqlDefs.FIELD_TYPE_LONG,
MysqlDefs.FIELD_TYPE_LONGLONG,
MysqlDefs.FIELD_TYPE_FLOAT });
}
return getShortFromString(stringVal, columnIndex + 1);
}
}
|
protected String getNativeString(int columnIndex) throws SQLException {
checkRowPos();
checkColumnBounds(columnIndex);
if (this.fields == null) {
throw SQLError.createSQLException(
Messages
.getString("ResultSet.Query_generated_no_fields_for_ResultSet_133"), //$NON-NLS-1$
SQLError.SQL_STATE_INVALID_COLUMN_NUMBER, getExceptionInterceptor());
}
if (this.thisRow.isNull(columnIndex - 1)) {
this.wasNullFlag = true;
return null;
}
this.wasNullFlag = false;
String stringVal = null;
Field field = this.fields[columnIndex - 1];
// TODO: Check Types Here.
stringVal = getNativeConvertToString(columnIndex, field);
int mysqlType = field.getMysqlType();
if (mysqlType != MysqlDefs.FIELD_TYPE_TIMESTAMP &&
mysqlType != MysqlDefs.FIELD_TYPE_DATE &&
field.isZeroFill() && (stringVal != null)) {
int origLength = stringVal.length();
StringBuffer zeroFillBuf = new StringBuffer(origLength);
long numZeros = field.getLength() - origLength;
for (long i = 0; i < numZeros; i++) {
zeroFillBuf.append('0');
}
zeroFillBuf.append(stringVal);
stringVal = zeroFillBuf.toString();
}
return stringVal;
}
Get the value of a column in the current row as a Java String |
Time getNativeTimeViaParseConversion(int columnIndex,
Calendar targetCalendar,
TimeZone tz,
boolean rollForward) throws SQLException {
if (this.useUsageAdvisor) {
issueConversionViaParsingWarning("getTime()", columnIndex,
this.thisRow.getColumnValue(columnIndex - 1), this.fields[columnIndex - 1],
new int[] { MysqlDefs.FIELD_TYPE_TIME });
}
String strTime = getNativeString(columnIndex);
return getTimeFromString(strTime, targetCalendar, columnIndex, tz, rollForward);
}
|
Timestamp getNativeTimestampViaParseConversion(int columnIndex,
Calendar targetCalendar,
TimeZone tz,
boolean rollForward) throws SQLException {
if (this.useUsageAdvisor) {
issueConversionViaParsingWarning("getTimestamp()", columnIndex,
this.thisRow.getColumnValue(columnIndex - 1), this.fields[columnIndex - 1],
new int[] { MysqlDefs.FIELD_TYPE_TIMESTAMP,
MysqlDefs.FIELD_TYPE_DATETIME });
}
String strTimestamp = getNativeString(columnIndex);
return getTimestampFromString(columnIndex, targetCalendar, strTimestamp, tz,
rollForward);
}
|
protected URL getNativeURL(int colIndex) throws SQLException {
String val = getString(colIndex);
if (val == null) {
return null;
}
try {
return new URL(val);
} catch (MalformedURLException mfe) {
throw SQLError.createSQLException(Messages
.getString("ResultSet.Malformed_URL____141")
+ val + "'", SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
}
}
|
protected InputStream getNativeUnicodeStream(int columnIndex) throws SQLException {
checkRowPos();
return getBinaryStream(columnIndex);
}
A column value can also be retrieved as a stream of Unicode characters.
We implement this as a binary stream. |
public ResultSetInternalMethods getNextResultSet() {
return this.nextResultSet;
}
|
public Object getObject(int columnIndex) throws SQLException {
checkRowPos();
checkColumnBounds(columnIndex);
int columnIndexMinusOne = columnIndex - 1;
if (this.thisRow.isNull(columnIndexMinusOne)) {
this.wasNullFlag = true;
return null;
}
this.wasNullFlag = false;
Field field;
field = this.fields[columnIndexMinusOne];
switch (field.getSQLType()) {
case Types.BIT:
case Types.BOOLEAN:
if (field.getMysqlType() == MysqlDefs.FIELD_TYPE_BIT
&& !field.isSingleBit()) {
return getBytes(columnIndex);
}
// valueOf would be nicer here, but it isn't
// present in JDK-1.3.1, which is what the CTS
// uses.
return Boolean.valueOf(getBoolean(columnIndex));
case Types.TINYINT:
if (!field.isUnsigned()) {
return Constants.integerValueOf(getByte(columnIndex));
}
return Constants.integerValueOf(getInt(columnIndex));
case Types.SMALLINT:
return Constants.integerValueOf(getInt(columnIndex));
case Types.INTEGER:
if (!field.isUnsigned() ||
field.getMysqlType() == MysqlDefs.FIELD_TYPE_INT24) {
return Constants.integerValueOf(getInt(columnIndex));
}
return Constants.longValueOf(getLong(columnIndex));
case Types.BIGINT:
if (!field.isUnsigned()) {
return Constants.longValueOf(getLong(columnIndex));
}
String stringVal = getString(columnIndex);
if (stringVal == null) {
return null;
}
try {
return new BigInteger(stringVal);
} catch (NumberFormatException nfe) {
throw SQLError.createSQLException(Messages.getString(
"ResultSet.Bad_format_for_BigInteger", new Object[] {
Constants.integerValueOf(columnIndex), stringVal }),
SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
}
case Types.DECIMAL:
case Types.NUMERIC:
stringVal = getString(columnIndex);
BigDecimal val;
if (stringVal != null) {
if (stringVal.length() == 0) {
val = new BigDecimal(0);
return val;
}
try {
val = new BigDecimal(stringVal);
} catch (NumberFormatException ex) {
throw SQLError.createSQLException(
Messages
.getString("ResultSet.Bad_format_for_BigDecimal", //$NON-NLS-1$
new Object[] {stringVal, new Integer(columnIndex)}),
SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
}
return val;
}
return null;
case Types.REAL:
return new Float(getFloat(columnIndex));
case Types.FLOAT:
case Types.DOUBLE:
return new Double(getDouble(columnIndex));
case Types.CHAR:
case Types.VARCHAR:
if (!field.isOpaqueBinary()) {
return getString(columnIndex);
}
return getBytes(columnIndex);
case Types.LONGVARCHAR:
if (!field.isOpaqueBinary()) {
return getStringForClob(columnIndex);
}
return getBytes(columnIndex);
case Types.BINARY:
case Types.VARBINARY:
case Types.LONGVARBINARY:
if (field.getMysqlType() == MysqlDefs.FIELD_TYPE_GEOMETRY) {
return getBytes(columnIndex);
} else if (field.isBinary() || field.isBlob()) {
byte[] data = getBytes(columnIndex);
if (this.connection.getAutoDeserialize()) {
Object obj = data;
if ((data != null) && (data.length >= 2)) {
if ((data[0] == -84) && (data[1] == -19)) {
// Serialized object?
try {
ByteArrayInputStream bytesIn = new ByteArrayInputStream(
data);
ObjectInputStream objIn = new ObjectInputStream(
bytesIn);
obj = objIn.readObject();
objIn.close();
bytesIn.close();
} catch (ClassNotFoundException cnfe) {
throw SQLError.createSQLException(
Messages
.getString("ResultSet.Class_not_found___91") //$NON-NLS-1$
+ cnfe.toString()
+ Messages
.getString("ResultSet._while_reading_serialized_object_92"), getExceptionInterceptor()); //$NON-NLS-1$
} catch (IOException ex) {
obj = data; // not serialized?
}
} else {
return getString(columnIndex);
}
}
return obj;
}
return data;
}
return getBytes(columnIndex);
case Types.DATE:
if (field.getMysqlType() == MysqlDefs.FIELD_TYPE_YEAR
&& !this.connection.getYearIsDateType()) {
return Constants.shortValueOf(getShort(columnIndex));
}
return getDate(columnIndex);
case Types.TIME:
return getTime(columnIndex);
case Types.TIMESTAMP:
return getTimestamp(columnIndex);
default:
return getString(columnIndex);
}
}
Get the value of a column in the current row as a Java object
This method will return the value of the given column as a Java object.
The type of the Java object will be the default Java Object type
corresponding to the column's SQL type, following the mapping specified
in the JDBC specification.
This method may also be used to read database specific abstract data
types.
|
public Object getObject(String columnName) throws SQLException {
return getObject(findColumn(columnName));
}
Get the value of a column in the current row as a Java object
This method will return the value of the given column as a Java object.
The type of the Java object will be the default Java Object type
corresponding to the column's SQL type, following the mapping specified
in the JDBC specification.
This method may also be used to read database specific abstract data
types.
|
public Object getObject(int i,
Map map) throws SQLException {
return getObject(i);
}
JDBC 2.0 Returns the value of column i as a Java object. Use the map to
determine the class from which to construct data of SQL structured and
distinct types. |
public Object getObject(String colName,
Map map) throws SQLException {
return getObject(findColumn(colName), map);
}
JDBC 2.0 Returns the value of column i as a Java object. Use the map to
determine the class from which to construct data of SQL structured and
distinct types. |
public Object getObjectStoredProc(int columnIndex,
int desiredSqlType) throws SQLException {
checkRowPos();
checkColumnBounds(columnIndex);
Object value = this.thisRow.getColumnValue(columnIndex - 1);
if (value == null) {
this.wasNullFlag = true;
return null;
}
this.wasNullFlag = false;
Field field;
field = this.fields[columnIndex - 1];
switch (desiredSqlType) {
case Types.BIT:
case Types.BOOLEAN:
// valueOf would be nicer here, but it isn't
// present in JDK-1.3.1, which is what the CTS
// uses.
return Boolean.valueOf(getBoolean(columnIndex));
case Types.TINYINT:
return Constants.integerValueOf(getInt(columnIndex));
case Types.SMALLINT:
return Constants.integerValueOf(getInt(columnIndex));
case Types.INTEGER:
if (!field.isUnsigned() ||
field.getMysqlType() == MysqlDefs.FIELD_TYPE_INT24) {
return Constants.integerValueOf(getInt(columnIndex));
}
return Constants.longValueOf(getLong(columnIndex));
case Types.BIGINT:
if (field.isUnsigned()) {
return getBigDecimal(columnIndex);
}
return Constants.longValueOf(getLong(columnIndex));
case Types.DECIMAL:
case Types.NUMERIC:
String stringVal = getString(columnIndex);
BigDecimal val;
if (stringVal != null) {
if (stringVal.length() == 0) {
val = new BigDecimal(0);
return val;
}
try {
val = new BigDecimal(stringVal);
} catch (NumberFormatException ex) {
throw SQLError.createSQLException(
Messages
.getString("ResultSet.Bad_format_for_BigDecimal", //$NON-NLS-1$
new Object[] {stringVal, new Integer(columnIndex)}),
SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
}
return val;
}
return null;
case Types.REAL:
return new Float(getFloat(columnIndex));
case Types.FLOAT:
if (!this.connection.getRunningCTS13()) {
return new Double(getFloat(columnIndex));
} else {
return new Float(getFloat(columnIndex)); // NB - bug in JDBC
// compliance test,
// according
// to JDBC spec, FLOAT type should return DOUBLE
// but causes ClassCastException in CTS :(
}
case Types.DOUBLE:
return new Double(getDouble(columnIndex));
case Types.CHAR:
case Types.VARCHAR:
return getString(columnIndex);
case Types.LONGVARCHAR:
return getStringForClob(columnIndex);
case Types.BINARY:
case Types.VARBINARY:
case Types.LONGVARBINARY:
return getBytes(columnIndex);
case Types.DATE:
if (field.getMysqlType() == MysqlDefs.FIELD_TYPE_YEAR
&& !this.connection.getYearIsDateType()) {
return Constants.shortValueOf(getShort(columnIndex));
}
return getDate(columnIndex);
case Types.TIME:
return getTime(columnIndex);
case Types.TIMESTAMP:
return getTimestamp(columnIndex);
default:
return getString(columnIndex);
}
}
|
public Object getObjectStoredProc(String columnName,
int desiredSqlType) throws SQLException {
return getObjectStoredProc(findColumn(columnName), desiredSqlType);
}
|
public Object getObjectStoredProc(int i,
Map map,
int desiredSqlType) throws SQLException {
return getObjectStoredProc(i, desiredSqlType);
}
|
public Object getObjectStoredProc(String colName,
Map map,
int desiredSqlType) throws SQLException {
return getObjectStoredProc(findColumn(colName), map, desiredSqlType);
}
|
public Ref getRef(int i) throws SQLException {
checkColumnBounds(i);
throw SQLError.notImplemented();
}
JDBC 2.0 Get a REF(<structured-type>) column. |
public Ref getRef(String colName) throws SQLException {
return getRef(findColumn(colName));
}
JDBC 2.0 Get a REF(<structured-type>) column. |
public int getRow() throws SQLException {
checkClosed();
int currentRowNumber = this.rowData.getCurrentRowNumber();
int row = 0;
// Non-dynamic result sets can be interrogated
// for this information
if (!this.rowData.isDynamic()) {
if ((currentRowNumber < 0) || this.rowData.isAfterLast()
|| this.rowData.isEmpty()) {
row = 0;
} else {
row = currentRowNumber + 1;
}
} else {
// dynamic (streaming) can not
row = currentRowNumber + 1;
}
return row;
}
JDBC 2.0
Determine the current row number. The first row is number 1, the second
number 2, etc.
|
public String getServerInfo() {
return this.serverInfo;
}
Returns the server info (if any), or null if none. |
public short getShort(int columnIndex) throws SQLException {
if (!this.isBinaryEncoded) {
checkRowPos();
if (this.useFastIntParsing) {
checkColumnBounds(columnIndex);
Object value = this.thisRow.getColumnValue(columnIndex - 1);
if (value == null) {
this.wasNullFlag = true;
} else {
this.wasNullFlag = false;
}
if (this.wasNullFlag) {
return 0;
}
byte[] shortAsBytes = (byte[]) value;
if (shortAsBytes.length == 0) {
return (short) convertToZeroWithEmptyCheck();
}
boolean needsFullParse = false;
for (int i = 0; i < shortAsBytes.length; i++) {
if (((char) shortAsBytes[i] == 'e')
|| ((char) shortAsBytes[i] == 'E')) {
needsFullParse = true;
break;
}
}
if (!needsFullParse) {
try {
return parseShortWithOverflowCheck(columnIndex,
shortAsBytes, null);
} catch (NumberFormatException nfe) {
try {
// To do: Warn of over/underflow???
return parseShortAsDouble(columnIndex, new String(
shortAsBytes));
} catch (NumberFormatException newNfe) {
; // ignore, it's not a number
}
if (this.fields[columnIndex - 1].getMysqlType() == MysqlDefs.FIELD_TYPE_BIT) {
long valueAsLong = getNumericRepresentationOfSQLBitType(columnIndex);
if (this.jdbcCompliantTruncationForReads &&
(valueAsLong < Short.MIN_VALUE
|| valueAsLong > Short.MAX_VALUE)) {
throwRangeException(String.valueOf(valueAsLong), columnIndex,
Types.SMALLINT);
}
return (short)valueAsLong;
}
throw SQLError.createSQLException(
Messages
.getString("ResultSet.Invalid_value_for_getShort()_-____96")
+ new String(shortAsBytes) //$NON-NLS-1$
+ "'",
SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
}
}
}
String val = null;
try {
val = getString(columnIndex);
if ((val != null)) {
if (val.length() == 0) {
return (short) convertToZeroWithEmptyCheck();
}
if ((val.indexOf("e") == -1) && (val.indexOf("E") == -1)
&& (val.indexOf(".") == -1)) {
return parseShortWithOverflowCheck(columnIndex, null,
val);
}
// Convert floating point
return parseShortAsDouble(columnIndex, val);
}
return 0; // for NULL
} catch (NumberFormatException nfe) {
try {
return parseShortAsDouble(columnIndex, val);
} catch (NumberFormatException newNfe) {
; // ignore, it's not a number
}
if (this.fields[columnIndex - 1].getMysqlType() == MysqlDefs.FIELD_TYPE_BIT) {
long valueAsLong = getNumericRepresentationOfSQLBitType(columnIndex);
if (this.jdbcCompliantTruncationForReads &&
(valueAsLong < Short.MIN_VALUE
|| valueAsLong > Short.MAX_VALUE)) {
throwRangeException(String.valueOf(valueAsLong), columnIndex,
Types.SMALLINT);
}
return (short)valueAsLong;
}
throw SQLError.createSQLException(
Messages
.getString("ResultSet.Invalid_value_for_getShort()_-____96")
+ val //$NON-NLS-1$
+ "'", SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
}
}
return getNativeShort(columnIndex);
}
Get the value of a column in the current row as a Java short. |
public short getShort(String columnName) throws SQLException {
return getShort(findColumn(columnName));
}
|
public Statement getStatement() throws SQLException {
if (this.isClosed && !this.retainOwningStatement) {
throw SQLError.createSQLException(
"Operation not allowed on closed ResultSet. Statements "
+ "can be retained over result set closure by setting the connection property "
+ "\"retainStatementAfterResultSetClose\" to \"true\".",
SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
}
if (this.wrapperStatement != null) {
return this.wrapperStatement;
}
return this.owningStatement;
}
JDBC 2.0 Return the Statement that produced the ResultSet. |
public String getString(int columnIndex) throws SQLException {
String stringVal = getStringInternal(columnIndex, true);
if (this.padCharsWithSpace && stringVal != null) {
Field f = this.fields[columnIndex - 1];
if (f.getMysqlType() == MysqlDefs.FIELD_TYPE_STRING ) {
int fieldLength = (int)f.getLength() /* safe, bytes in a CHAR < = 1024 */ /
f.getMaxBytesPerCharacter(); /* safe, this will never be 0 */
int currentLength = stringVal.length();
if (currentLength < fieldLength) {
StringBuffer paddedBuf = new StringBuffer(fieldLength);
paddedBuf.append(stringVal);
int difference = fieldLength - currentLength;
paddedBuf.append(EMPTY_SPACE, 0, difference);
stringVal = paddedBuf.toString();
}
}
}
return stringVal;
}
Get the value of a column in the current row as a Java String |
public String getString(String columnName) throws SQLException {
return getString(findColumn(columnName));
}
The following routines simply convert the columnName into a columnIndex
and then call the appropriate routine above. |
protected String getStringInternal(int columnIndex,
boolean checkDateTypes) throws SQLException {
if (!this.isBinaryEncoded) {
checkRowPos();
checkColumnBounds(columnIndex);
if (this.fields == null) {
throw SQLError.createSQLException(
Messages
.getString("ResultSet.Query_generated_no_fields_for_ResultSet_99"), //$NON-NLS-1$
SQLError.SQL_STATE_INVALID_COLUMN_NUMBER, getExceptionInterceptor());
}
// JDBC is 1-based, Java is not !?
int internalColumnIndex = columnIndex - 1;
if (this.thisRow.isNull(internalColumnIndex)) {
this.wasNullFlag = true;
return null;
}
this.wasNullFlag = false;
Field metadata = this.fields[internalColumnIndex];
String stringVal = null;
if (metadata.getMysqlType() == MysqlDefs.FIELD_TYPE_BIT) {
if (metadata.isSingleBit()) {
byte[] value = this.thisRow.getColumnValue(internalColumnIndex);
if (value.length == 0) {
return String.valueOf(convertToZeroWithEmptyCheck());
}
return String.valueOf(value[0]);
}
return String.valueOf(getNumericRepresentationOfSQLBitType(columnIndex));
}
String encoding = metadata.getCharacterSet();
stringVal = this.thisRow.getString(internalColumnIndex, encoding, this.connection);
//
// Special handling for YEAR type from mysql, some people
// want it as a DATE, others want to treat it as a SHORT
//
if (metadata.getMysqlType() == MysqlDefs.FIELD_TYPE_YEAR) {
if (!this.connection.getYearIsDateType()) {
return stringVal;
}
Date dt = getDateFromString(stringVal, columnIndex, null);
if (dt == null) {
this.wasNullFlag = true;
return null;
}
this.wasNullFlag = false;
return dt.toString();
}
// Handles timezone conversion and zero-date behavior
if (checkDateTypes && !this.connection.getNoDatetimeStringSync()) {
switch (metadata.getSQLType()) {
case Types.TIME:
Time tm = getTimeFromString(stringVal, null, columnIndex,
this.getDefaultTimeZone(), false);
if (tm == null) {
this.wasNullFlag = true;
return null;
}
this.wasNullFlag = false;
return tm.toString();
case Types.DATE:
Date dt = getDateFromString(stringVal, columnIndex, null);
if (dt == null) {
this.wasNullFlag = true;
return null;
}
this.wasNullFlag = false;
return dt.toString();
case Types.TIMESTAMP:
Timestamp ts = getTimestampFromString(columnIndex,
null, stringVal, this.getDefaultTimeZone(), false);
if (ts == null) {
this.wasNullFlag = true;
return null;
}
this.wasNullFlag = false;
return ts.toString();
default:
break;
}
}
return stringVal;
}
return getNativeString(columnIndex);
}
|
public Time getTime(int columnIndex) throws SQLException {
return getTimeInternal(columnIndex, null, this.getDefaultTimeZone(), false);
}
Get the value of a column in the current row as a java.sql.Time object |
public Time getTime(String columnName) throws SQLException {
return getTime(findColumn(columnName));
}
Get the value of a column in the current row as a java.sql.Time object. |
public Time getTime(int columnIndex,
Calendar cal) throws SQLException {
return getTimeInternal(columnIndex, cal, cal.getTimeZone(), true);
}
Get the value of a column in the current row as a java.sql.Time object.
Use the calendar to construct an appropriate millisecond value for the
Time, if the underlying database doesn't store timezone information. |
public Time getTime(String columnName,
Calendar cal) throws SQLException {
return getTime(findColumn(columnName), cal);
}
Get the value of a column in the current row as a java.sql.Time object.
Use the calendar to construct an appropriate millisecond value for the
Time, if the underlying database doesn't store timezone information. |
public Timestamp getTimestamp(int columnIndex) throws SQLException {
return getTimestampInternal(columnIndex, null, this.getDefaultTimeZone(),
false);
}
Get the value of a column in the current row as a java.sql.Timestamp
object |
public Timestamp getTimestamp(String columnName) throws SQLException {
return getTimestamp(findColumn(columnName));
}
|
public Timestamp getTimestamp(int columnIndex,
Calendar cal) throws SQLException {
return getTimestampInternal(columnIndex, cal, cal.getTimeZone(), true);
}
Get the value of a column in the current row as a java.sql.Timestamp
object. Use the calendar to construct an appropriate millisecond value
for the Timestamp, if the underlying database doesn't store timezone
information. |
public Timestamp getTimestamp(String columnName,
Calendar cal) throws SQLException {
return getTimestamp(findColumn(columnName), cal);
}
Get the value of a column in the current row as a java.sql.Timestamp
object. Use the calendar to construct an appropriate millisecond value
for the Timestamp, if the underlying database doesn't store timezone
information. |
public int getType() throws SQLException {
return this.resultSetType;
}
JDBC 2.0 Return the type of this result set. The type is determined based
on the statement that created the result set. |
public URL getURL(int colIndex) throws SQLException {
String val = getString(colIndex);
if (val == null) {
return null;
}
try {
return new URL(val);
} catch (MalformedURLException mfe) {
throw SQLError.createSQLException(Messages
.getString("ResultSet.Malformed_URL____104")
+ val + "'", SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
}
}
|
public URL getURL(String colName) throws SQLException {
String val = getString(colName);
if (val == null) {
return null;
}
try {
return new URL(val);
} catch (MalformedURLException mfe) {
throw SQLError.createSQLException(Messages
.getString("ResultSet.Malformed_URL____107")
+ val + "'", SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
}
}
|
public InputStream getUnicodeStream(int columnIndex) throws SQLException {
if (!this.isBinaryEncoded) {
checkRowPos();
return getBinaryStream(columnIndex);
}
return getNativeBinaryStream(columnIndex);
} Deprecated!
A column value can also be retrieved as a stream of Unicode characters.
We implement this as a binary stream. |
public InputStream getUnicodeStream(String columnName) throws SQLException {
return getUnicodeStream(findColumn(columnName));
} Deprecated!
|
public long getUpdateCount() {
return this.updateCount;
}
|
public long getUpdateID() {
return this.updateId;
}
|
public SQLWarning getWarnings() throws SQLException {
return this.warningChain;
}
The first warning reported by calls on this ResultSet is returned.
Subsequent ResultSet warnings will be chained to this
java.sql.SQLWarning.
The warning chain is automatically cleared each time a new row is read.
Note: This warning chain only covers warnings caused by ResultSet
methods. Any warnings caused by statement methods (such as reading OUT
parameters) will be chained on the Statement object.
|
public void initializeFromCachedMetaData(CachedResultSetMetaData cachedMetaData) {
this.fields = cachedMetaData.fields;
this.columnLabelToIndex = cachedMetaData.columnNameToIndex;
this.fullColumnNameToIndex = cachedMetaData.fullColumnNameToIndex;
this.hasBuiltIndexMapping = true;
}
|
public void initializeWithMetadata() throws SQLException {
this.rowData.setMetadata(this.fields);
this.columnToIndexCache = new HashMap();
if (this.profileSql || this.connection.getUseUsageAdvisor()) {
this.columnUsed = new boolean[this.fields.length];
this.pointOfOrigin = new Throwable();
this.resultId = resultCounter++;
this.useUsageAdvisor = this.connection.getUseUsageAdvisor();
this.eventSink = ProfilerEventHandlerFactory.getInstance(this.connection);
}
if (this.connection.getGatherPerformanceMetrics()) {
this.connection.incrementNumberOfResultSetsCreated();
Map tableNamesMap = new HashMap();
for (int i = 0; i < this.fields.length; i++) {
Field f = this.fields[i];
String tableName = f.getOriginalTableName();
if (tableName == null) {
tableName = f.getTableName();
}
if (tableName != null) {
if (this.connection.lowerCaseTableNames()) {
tableName = tableName.toLowerCase(); // on windows, table
// names are not case-sens.
}
tableNamesMap.put(tableName, null);
}
}
this.connection.reportNumberOfTablesAccessed(tableNamesMap.size());
}
}
|
public void insertRow() throws SQLException {
throw new NotUpdatable();
}
JDBC 2.0 Insert the contents of the insert row into the result set and
the database. Must be on the insert row when this method is called. |
public boolean isAfterLast() throws SQLException {
checkClosed();
boolean b = this.rowData.isAfterLast();
return b;
}
|
public boolean isBeforeFirst() throws SQLException {
checkClosed();
return this.rowData.isBeforeFirst();
}
|
public boolean isFirst() throws SQLException {
checkClosed();
return this.rowData.isFirst();
}
|
public boolean isLast() throws SQLException {
checkClosed();
return this.rowData.isLast();
}
JDBC 2.0
Determine if the cursor is on the last row of the result set. Note:
Calling isLast() may be expensive since the JDBC driver might need to
fetch ahead one row in order to determine whether the current row is the
last row in the result set.
|
public boolean last() throws SQLException {
checkClosed();
boolean b = true;
if (this.rowData.size() == 0) {
b = false;
} else {
if (this.onInsertRow) {
this.onInsertRow = false;
}
if (this.doingUpdates) {
this.doingUpdates = false;
}
if (this.thisRow != null) {
this.thisRow.closeOpenStreams();
}
this.rowData.beforeLast();
this.thisRow = this.rowData.next();
}
setRowPositionValidity();
return b;
}
|
public void moveToCurrentRow() throws SQLException {
throw new NotUpdatable();
}
JDBC 2.0 Move the cursor to the remembered cursor position, usually the
current row. Has no effect unless the cursor is on the insert row. |
public void moveToInsertRow() throws SQLException {
throw new NotUpdatable();
}
JDBC 2.0 Move to the insert row. The current cursor position is
remembered while the cursor is positioned on the insert row. The insert
row is a special row associated with an updatable result set. It is
essentially a buffer where a new row may be constructed by calling the
updateXXX() methods prior to inserting the row into the result set. Only
the updateXXX(), getXXX(), and insertRow() methods may be called when the
cursor is on the insert row. All of the columns in a result set must be
given a value each time this method is called before calling insertRow().
UpdateXXX()must be called before getXXX() on a column. |
public boolean next() throws SQLException {
checkClosed();
if (this.onInsertRow) {
this.onInsertRow = false;
}
if (this.doingUpdates) {
this.doingUpdates = false;
}
boolean b;
if (!reallyResult()) {
throw SQLError.createSQLException(
Messages
.getString("ResultSet.ResultSet_is_from_UPDATE._No_Data_115"),
SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor()); //$NON-NLS-1$
}
if (this.thisRow != null) {
this.thisRow.closeOpenStreams();
}
if (this.rowData.size() == 0) {
b = false;
} else {
this.thisRow = this.rowData.next();
if (this.thisRow == null) {
b = false;
} else {
clearWarnings();
b = true;
}
}
setRowPositionValidity();
return b;
}
A ResultSet is initially positioned before its first row, the first call
to next makes the first row the current row; the second call makes the
second row the current row, etc.
If an input stream from the previous row is open, it is implicitly
closed. The ResultSet's warning chain is cleared when a new row is read
|
public void populateCachedMetaData(CachedResultSetMetaData cachedMetaData) throws SQLException {
cachedMetaData.fields = this.fields;
cachedMetaData.columnNameToIndex = this.columnLabelToIndex;
cachedMetaData.fullColumnNameToIndex = this.fullColumnNameToIndex;
cachedMetaData.metadata = getMetaData();
}
|
public boolean prev() throws SQLException {
checkClosed();
int rowIndex = this.rowData.getCurrentRowNumber();
if (this.thisRow != null) {
this.thisRow.closeOpenStreams();
}
boolean b = true;
if ((rowIndex - 1) >= 0) {
rowIndex--;
this.rowData.setCurrentRow(rowIndex);
this.thisRow = this.rowData.getAt(rowIndex);
b = true;
} else if ((rowIndex - 1) == -1) {
rowIndex--;
this.rowData.setCurrentRow(rowIndex);
this.thisRow = null;
b = false;
} else {
b = false;
}
setRowPositionValidity();
return b;
}
The prev method is not part of JDBC, but because of the architecture of
this driver it is possible to move both forward and backward within the
result set.
If an input stream from the previous row is open, it is implicitly
closed. The ResultSet's warning chain is cleared when a new row is read
|
public boolean previous() throws SQLException {
if (this.onInsertRow) {
this.onInsertRow = false;
}
if (this.doingUpdates) {
this.doingUpdates = false;
}
return prev();
}
JDBC 2.0
Moves to the previous row in the result set.
Note: previous() is not the same as relative(-1) since it makes sense to
call previous() when there is no current row.
|
public void realClose(boolean calledExplicitly) throws SQLException {
if (this.isClosed) {
return;
}
try {
if (this.useUsageAdvisor) {
// Report on result set closed by driver instead of application
if (!calledExplicitly) {
this.eventSink
.consumeEvent(new ProfilerEvent(
ProfilerEvent.TYPE_WARN,
"",
(this.owningStatement == null) ? "N/A"
: this.owningStatement.currentCatalog,
this.connectionId,
(this.owningStatement == null) ? (-1)
: this.owningStatement.getId(),
this.resultId,
System.currentTimeMillis(),
0,
Constants.MILLIS_I18N,
null,
this.pointOfOrigin,
Messages
.getString("ResultSet.ResultSet_implicitly_closed_by_driver"))); //$NON-NLS-1$
}
if (this.rowData instanceof RowDataStatic) {
// Report on possibly too-large result sets
if (this.rowData.size() > this.connection
.getResultSetSizeThreshold()) {
this.eventSink
.consumeEvent(new ProfilerEvent(
ProfilerEvent.TYPE_WARN,
"",
(this.owningStatement == null) ? Messages
.getString("ResultSet.N/A_159")
: this.owningStatement.currentCatalog, //$NON-NLS-1$
this.connectionId,
(this.owningStatement == null) ? (-1)
: this.owningStatement.getId(),
this.resultId,
System.currentTimeMillis(),
0,
Constants.MILLIS_I18N,
null,
this.pointOfOrigin,
Messages
.getString(
"ResultSet.Too_Large_Result_Set",
new Object[] {
new Integer(
this.rowData
.size()),
new Integer(
this.connection
.getResultSetSizeThreshold()) })));
}
if (!isLast() && !isAfterLast() && (this.rowData.size() != 0)) {
this.eventSink
.consumeEvent(new ProfilerEvent(
ProfilerEvent.TYPE_WARN,
"",
(this.owningStatement == null) ? Messages
.getString("ResultSet.N/A_159")
: this.owningStatement.currentCatalog, //$NON-NLS-1$
this.connectionId,
(this.owningStatement == null) ? (-1)
: this.owningStatement.getId(),
this.resultId,
System.currentTimeMillis(),
0,
Constants.MILLIS_I18N,
null,
this.pointOfOrigin,
Messages
.getString(
"ResultSet.Possible_incomplete_traversal_of_result_set", //$NON-NLS-1$
new Object[] {
new Integer(
getRow()),
new Integer(
this.rowData
.size()) })));
}
}
//
// Report on any columns that were selected but
// not referenced
//
if (this.columnUsed.length > 0 && !this.rowData.wasEmpty()) {
StringBuffer buf = new StringBuffer(
Messages
.getString("ResultSet.The_following_columns_were_never_referenced")); //$NON-NLS-1$
boolean issueWarn = false;
for (int i = 0; i < this.columnUsed.length; i++) {
if (!this.columnUsed[i]) {
if (!issueWarn) {
issueWarn = true;
} else {
buf.append(", ");
}
buf.append(this.fields[i].getFullName());
}
}
if (issueWarn) {
this.eventSink.consumeEvent(new ProfilerEvent(
ProfilerEvent.TYPE_WARN, "",
(this.owningStatement == null) ? "N/A"
: this.owningStatement.currentCatalog,
this.connectionId,
(this.owningStatement == null) ? (-1)
: this.owningStatement.getId(), 0,
System.currentTimeMillis(), 0,
Constants.MILLIS_I18N, null,
this.pointOfOrigin, buf.toString()));
}
}
}
} finally {
if (this.owningStatement != null && calledExplicitly) {
this.owningStatement.removeOpenResultSet(this);
}
SQLException exceptionDuringClose = null;
if (this.rowData != null) {
try {
this.rowData.close();
} catch (SQLException sqlEx) {
exceptionDuringClose = sqlEx;
}
}
if (this.statementUsedForFetchingRows != null) {
try {
this.statementUsedForFetchingRows.realClose(true, false);
} catch (SQLException sqlEx) {
if (exceptionDuringClose != null) {
exceptionDuringClose.setNextException(sqlEx);
} else {
exceptionDuringClose = sqlEx;
}
}
}
this.rowData = null;
this.defaultTimeZone = null;
this.fields = null;
this.columnLabelToIndex = null;
this.fullColumnNameToIndex = null;
this.columnToIndexCache = null;
this.eventSink = null;
this.warningChain = null;
if (!this.retainOwningStatement) {
this.owningStatement = null;
}
this.catalog = null;
this.serverInfo = null;
this.thisRow = null;
this.fastDateCal = null;
this.connection = null;
this.isClosed = true;
if (exceptionDuringClose != null) {
throw exceptionDuringClose;
}
}
}
Closes this ResultSet and releases resources. |
public boolean reallyResult() {
if (this.rowData != null) {
return true;
}
return this.reallyResult;
}
|
public void redefineFieldsForDBMD(Field[] f) {
this.fields = f;
for (int i = 0; i < this.fields.length; i++) {
this.fields[i].setUseOldNameMetadata(true);
this.fields[i].setConnection(this.connection);
}
}
|
public void refreshRow() throws SQLException {
throw new NotUpdatable();
}
JDBC 2.0 Refresh the value of the current row with its current value in
the database. Cannot be called when on the insert row. The refreshRow()
method provides a way for an application to explicitly tell the JDBC
driver to refetch a row(s) from the database. An application may want to
call refreshRow() when caching or prefetching is being done by the JDBC
driver to fetch the latest value of a row from the database. The JDBC
driver may actually refresh multiple rows at once if the fetch size is
greater than one. All values are refetched subject to the transaction
isolation level and cursor sensitivity. If refreshRow() is called after
calling updateXXX(), but before calling updateRow() then the updates made
to the row are lost. Calling refreshRow() frequently will likely slow
performance. |
public boolean relative(int rows) throws SQLException {
checkClosed();
if (this.rowData.size() == 0) {
setRowPositionValidity();
return false;
}
if (this.thisRow != null) {
this.thisRow.closeOpenStreams();
}
this.rowData.moveRowRelative(rows);
this.thisRow = this.rowData.getAt(this.rowData.getCurrentRowNumber());
setRowPositionValidity();
return (!this.rowData.isAfterLast() && !this.rowData.isBeforeFirst());
}
JDBC 2.0
Moves a relative number of rows, either positive or negative. Attempting
to move beyond the first/last row in the result set positions the cursor
before/after the the first/last row. Calling relative(0) is valid, but
does not change the cursor position.
Note: Calling relative(1) is different than calling next() since is makes
sense to call next() when there is no current row, for example, when the
cursor is positioned before the first row or after the last row of the
result set.
|
public boolean rowDeleted() throws SQLException {
throw SQLError.notImplemented();
}
JDBC 2.0 Determine if this row has been deleted. A deleted row may leave
a visible "hole" in a result set. This method can be used to detect holes
in a result set. The value returned depends on whether or not the result
set can detect deletions. |
public boolean rowInserted() throws SQLException {
throw SQLError.notImplemented();
}
JDBC 2.0 Determine if the current row has been inserted. The value
returned depends on whether or not the result set can detect visible
inserts. |
public boolean rowUpdated() throws SQLException {
throw SQLError.notImplemented();
}
JDBC 2.0 Determine if the current row has been updated. The value
returned depends on whether or not the result set can detect updates. |
protected void setBinaryEncoded() {
this.isBinaryEncoded = true;
}
Flag that this result set is 'binary' encoded (from a PreparedStatement),
not stored as strings. |
public void setFetchDirection(int direction) throws SQLException {
if ((direction != FETCH_FORWARD) && (direction != FETCH_REVERSE)
&& (direction != FETCH_UNKNOWN)) {
throw SQLError.createSQLException(
Messages
.getString("ResultSet.Illegal_value_for_fetch_direction_64"),
SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); //$NON-NLS-1$
}
this.fetchDirection = direction;
}
JDBC 2.0 Give a hint as to the direction in which the rows in this result
set will be processed. The initial value is determined by the statement
that produced the result set. The fetch direction may be changed at any
time. |
public void setFetchSize(int rows) throws SQLException {
if (rows < 0) { /* || rows > getMaxRows() */
throw SQLError.createSQLException(
Messages
.getString("ResultSet.Value_must_be_between_0_and_getMaxRows()_66"), //$NON-NLS-1$
SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
}
this.fetchSize = rows;
}
JDBC 2.0 Give the JDBC driver a hint as to the number of rows that should
be fetched from the database when more rows are needed for this result
set. If the fetch size specified is zero, then the JDBC driver ignores
the value, and is free to make its own best guess as to what the fetch
size should be. The default value is set by the statement that creates
the result set. The fetch size may be changed at any time. |
public void setFirstCharOfQuery(char c) {
this.firstCharOfQuery = c;
}
Sets the first character of the query that this result set was created
from. |
protected void setNextResultSet(ResultSetInternalMethods nextResultSet) {
this.nextResultSet = nextResultSet;
}
|
public void setOwningStatement(StatementImpl owningStatement) {
this.owningStatement = owningStatement;
}
|
protected void setResultSetConcurrency(int concurrencyFlag) {
this.resultSetConcurrency = concurrencyFlag;
}
Sets the concurrency (JDBC2) |
protected void setResultSetType(int typeFlag) {
this.resultSetType = typeFlag;
}
Sets the result set type for (JDBC2) |
protected void setServerInfo(String info) {
this.serverInfo = info;
}
Sets server info (if any) |
public void setStatementUsedForFetchingRows(PreparedStatement stmt) {
this.statementUsedForFetchingRows = stmt;
}
|
public void setWrapperStatement(Statement wrapperStatement) {
this.wrapperStatement = wrapperStatement;
}
|
public String toString() {
if (this.reallyResult) {
return super.toString();
}
return "Result set representing update count of " + this.updateCount;
}
|
public void updateArray(int arg0,
Array arg1) throws SQLException {
throw SQLError.notImplemented();
}
|
public void updateArray(String arg0,
Array arg1) throws SQLException {
throw SQLError.notImplemented();
}
|
public void updateAsciiStream(int columnIndex,
InputStream x,
int length) throws SQLException {
throw new NotUpdatable();
}
JDBC 2.0 Update a column with an ascii stream value. The updateXXX()
methods are used to update column values in the current row, or the
insert row. The updateXXX() methods do not update the underlying
database, instead the updateRow() or insertRow() methods are called to
update the database. |
public void updateAsciiStream(String columnName,
InputStream x,
int length) throws SQLException {
updateAsciiStream(findColumn(columnName), x, length);
}
JDBC 2.0 Update a column with an ascii stream value. The updateXXX()
methods are used to update column values in the current row, or the
insert row. The updateXXX() methods do not update the underlying
database, instead the updateRow() or insertRow() methods are called to
update the database. |
public void updateBigDecimal(int columnIndex,
BigDecimal x) throws SQLException {
throw new NotUpdatable();
}
JDBC 2.0 Update a column with a BigDecimal value. The updateXXX() methods
are used to update column values in the current row, or the insert row.
The updateXXX() methods do not update the underlying database, instead
the updateRow() or insertRow() methods are called to update the database. |
public void updateBigDecimal(String columnName,
BigDecimal x) throws SQLException {
updateBigDecimal(findColumn(columnName), x);
}
JDBC 2.0 Update a column with a BigDecimal value. The updateXXX() methods
are used to update column values in the current row, or the insert row.
The updateXXX() methods do not update the underlying database, instead
the updateRow() or insertRow() methods are called to update the database. |
public void updateBinaryStream(int columnIndex,
InputStream x,
int length) throws SQLException {
throw new NotUpdatable();
}
JDBC 2.0 Update a column with a binary stream value. The updateXXX()
methods are used to update column values in the current row, or the
insert row. The updateXXX() methods do not update the underlying
database, instead the updateRow() or insertRow() methods are called to
update the database. |
public void updateBinaryStream(String columnName,
InputStream x,
int length) throws SQLException {
updateBinaryStream(findColumn(columnName), x, length);
}
JDBC 2.0 Update a column with a binary stream value. The updateXXX()
methods are used to update column values in the current row, or the
insert row. The updateXXX() methods do not update the underlying
database, instead the updateRow() or insertRow() methods are called to
update the database. |
public void updateBlob(int arg0,
Blob arg1) throws SQLException {
throw new NotUpdatable();
}
|
public void updateBlob(String arg0,
Blob arg1) throws SQLException {
throw new NotUpdatable();
}
|
public void updateBoolean(int columnIndex,
boolean x) throws SQLException {
throw new NotUpdatable();
}
JDBC 2.0 Update a column with a boolean value. The updateXXX() methods
are used to update column values in the current row, or the insert row.
The updateXXX() methods do not update the underlying database, instead
the updateRow() or insertRow() methods are called to update the database. |
public void updateBoolean(String columnName,
boolean x) throws SQLException {
updateBoolean(findColumn(columnName), x);
}
JDBC 2.0 Update a column with a boolean value. The updateXXX() methods
are used to update column values in the current row, or the insert row.
The updateXXX() methods do not update the underlying database, instead
the updateRow() or insertRow() methods are called to update the database. |
public void updateByte(int columnIndex,
byte x) throws SQLException {
throw new NotUpdatable();
}
JDBC 2.0 Update a column with a byte value. The updateXXX() methods are
used to update column values in the current row, or the insert row. The
updateXXX() methods do not update the underlying database, instead the
updateRow() or insertRow() methods are called to update the database. |
public void updateByte(String columnName,
byte x) throws SQLException {
updateByte(findColumn(columnName), x);
}
JDBC 2.0 Update a column with a byte value. The updateXXX() methods are
used to update column values in the current row, or the insert row. The
updateXXX() methods do not update the underlying database, instead the
updateRow() or insertRow() methods are called to update the database. |
public void updateBytes(int columnIndex,
byte[] x) throws SQLException {
throw new NotUpdatable();
}
JDBC 2.0 Update a column with a byte array value. The updateXXX() methods
are used to update column values in the current row, or the insert row.
The updateXXX() methods do not update the underlying database, instead
the updateRow() or insertRow() methods are called to update the database. |
public void updateBytes(String columnName,
byte[] x) throws SQLException {
updateBytes(findColumn(columnName), x);
}
JDBC 2.0 Update a column with a byte array value. The updateXXX() methods
are used to update column values in the current row, or the insert row.
The updateXXX() methods do not update the underlying database, instead
the updateRow() or insertRow() methods are called to update the database. |
public void updateCharacterStream(int columnIndex,
Reader x,
int length) throws SQLException {
throw new NotUpdatable();
}
JDBC 2.0 Update a column with a character stream value. The updateXXX()
methods are used to update column values in the current row, or the
insert row. The updateXXX() methods do not update the underlying
database, instead the updateRow() or insertRow() methods are called to
update the database. |
public void updateCharacterStream(String columnName,
Reader reader,
int length) throws SQLException {
updateCharacterStream(findColumn(columnName), reader, length);
}
JDBC 2.0 Update a column with a character stream value. The updateXXX()
methods are used to update column values in the current row, or the
insert row. The updateXXX() methods do not update the underlying
database, instead the updateRow() or insertRow() methods are called to
update the database. |
public void updateClob(int arg0,
Clob arg1) throws SQLException {
throw SQLError.notImplemented();
}
|
public void updateClob(String columnName,
Clob clob) throws SQLException {
updateClob(findColumn(columnName), clob);
}
|
public void updateDate(int columnIndex,
Date x) throws SQLException {
throw new NotUpdatable();
}
JDBC 2.0 Update a column with a Date value. The updateXXX() methods are
used to update column values in the current row, or the insert row. The
updateXXX() methods do not update the underlying database, instead the
updateRow() or insertRow() methods are called to update the database. |
public void updateDate(String columnName,
Date x) throws SQLException {
updateDate(findColumn(columnName), x);
}
JDBC 2.0 Update a column with a Date value. The updateXXX() methods are
used to update column values in the current row, or the insert row. The
updateXXX() methods do not update the underlying database, instead the
updateRow() or insertRow() methods are called to update the database. |
public void updateDouble(int columnIndex,
double x) throws SQLException {
throw new NotUpdatable();
}
JDBC 2.0 Update a column with a Double value. The updateXXX() methods are
used to update column values in the current row, or the insert row. The
updateXXX() methods do not update the underlying database, instead the
updateRow() or insertRow() methods are called to update the database. |
public void updateDouble(String columnName,
double x) throws SQLException {
updateDouble(findColumn(columnName), x);
}
JDBC 2.0 Update a column with a double value. The updateXXX() methods are
used to update column values in the current row, or the insert row. The
updateXXX() methods do not update the underlying database, instead the
updateRow() or insertRow() methods are called to update the database. |
public void updateFloat(int columnIndex,
float x) throws SQLException {
throw new NotUpdatable();
}
JDBC 2.0 Update a column with a float value. The updateXXX() methods are
used to update column values in the current row, or the insert row. The
updateXXX() methods do not update the underlying database, instead the
updateRow() or insertRow() methods are called to update the database. |
public void updateFloat(String columnName,
float x) throws SQLException {
updateFloat(findColumn(columnName), x);
}
JDBC 2.0 Update a column with a float value. The updateXXX() methods are
used to update column values in the current row, or the insert row. The
updateXXX() methods do not update the underlying database, instead the
updateRow() or insertRow() methods are called to update the database. |
public void updateInt(int columnIndex,
int x) throws SQLException {
throw new NotUpdatable();
}
JDBC 2.0 Update a column with an integer value. The updateXXX() methods
are used to update column values in the current row, or the insert row.
The updateXXX() methods do not update the underlying database, instead
the updateRow() or insertRow() methods are called to update the database. |
public void updateInt(String columnName,
int x) throws SQLException {
updateInt(findColumn(columnName), x);
}
JDBC 2.0 Update a column with an integer value. The updateXXX() methods
are used to update column values in the current row, or the insert row.
The updateXXX() methods do not update the underlying database, instead
the updateRow() or insertRow() methods are called to update the database. |
public void updateLong(int columnIndex,
long x) throws SQLException {
throw new NotUpdatable();
}
JDBC 2.0 Update a column with a long value. The updateXXX() methods are
used to update column values in the current row, or the insert row. The
updateXXX() methods do not update the underlying database, instead the
updateRow() or insertRow() methods are called to update the database. |
public void updateLong(String columnName,
long x) throws SQLException {
updateLong(findColumn(columnName), x);
}
JDBC 2.0 Update a column with a long value. The updateXXX() methods are
used to update column values in the current row, or the insert row. The
updateXXX() methods do not update the underlying database, instead the
updateRow() or insertRow() methods are called to update the database. |
public void updateNull(int columnIndex) throws SQLException {
throw new NotUpdatable();
}
JDBC 2.0 Give a nullable column a null value. The updateXXX() methods are
used to update column values in the current row, or the insert row. The
updateXXX() methods do not update the underlying database, instead the
updateRow() or insertRow() methods are called to update the database. |
public void updateNull(String columnName) throws SQLException {
updateNull(findColumn(columnName));
}
JDBC 2.0 Update a column with a null value. The updateXXX() methods are
used to update column values in the current row, or the insert row. The
updateXXX() methods do not update the underlying database, instead the
updateRow() or insertRow() methods are called to update the database. |
public void updateObject(int columnIndex,
Object x) throws SQLException {
throw new NotUpdatable();
}
JDBC 2.0 Update a column with an Object value. The updateXXX() methods
are used to update column values in the current row, or the insert row.
The updateXXX() methods do not update the underlying database, instead
the updateRow() or insertRow() methods are called to update the database. |
public void updateObject(String columnName,
Object x) throws SQLException {
updateObject(findColumn(columnName), x);
}
JDBC 2.0 Update a column with an Object value. The updateXXX() methods
are used to update column values in the current row, or the insert row.
The updateXXX() methods do not update the underlying database, instead
the updateRow() or insertRow() methods are called to update the database. |
public void updateObject(int columnIndex,
Object x,
int scale) throws SQLException {
throw new NotUpdatable();
}
JDBC 2.0 Update a column with an Object value. The updateXXX() methods
are used to update column values in the current row, or the insert row.
The updateXXX() methods do not update the underlying database, instead
the updateRow() or insertRow() methods are called to update the database. |
public void updateObject(String columnName,
Object x,
int scale) throws SQLException {
updateObject(findColumn(columnName), x);
}
JDBC 2.0 Update a column with an Object value. The updateXXX() methods
are used to update column values in the current row, or the insert row.
The updateXXX() methods do not update the underlying database, instead
the updateRow() or insertRow() methods are called to update the database. |
public void updateRef(int arg0,
Ref arg1) throws SQLException {
throw SQLError.notImplemented();
}
|
public void updateRef(String arg0,
Ref arg1) throws SQLException {
throw SQLError.notImplemented();
}
|
public void updateRow() throws SQLException {
throw new NotUpdatable();
}
JDBC 2.0 Update the underlying database with the new contents of the
current row. Cannot be called when on the insert row. |
public void updateShort(int columnIndex,
short x) throws SQLException {
throw new NotUpdatable();
}
JDBC 2.0 Update a column with a short value. The updateXXX() methods are
used to update column values in the current row, or the insert row. The
updateXXX() methods do not update the underlying database, instead the
updateRow() or insertRow() methods are called to update the database. |
public void updateShort(String columnName,
short x) throws SQLException {
updateShort(findColumn(columnName), x);
}
JDBC 2.0 Update a column with a short value. The updateXXX() methods are
used to update column values in the current row, or the insert row. The
updateXXX() methods do not update the underlying database, instead the
updateRow() or insertRow() methods are called to update the database. |
public void updateString(int columnIndex,
String x) throws SQLException {
throw new NotUpdatable();
}
JDBC 2.0 Update a column with a String value. The updateXXX() methods are
used to update column values in the current row, or the insert row. The
updateXXX() methods do not update the underlying database, instead the
updateRow() or insertRow() methods are called to update the database. |
public void updateString(String columnName,
String x) throws SQLException {
updateString(findColumn(columnName), x);
}
JDBC 2.0 Update a column with a String value. The updateXXX() methods are
used to update column values in the current row, or the insert row. The
updateXXX() methods do not update the underlying database, instead the
updateRow() or insertRow() methods are called to update the database. |
public void updateTime(int columnIndex,
Time x) throws SQLException {
throw new NotUpdatable();
}
JDBC 2.0 Update a column with a Time value. The updateXXX() methods are
used to update column values in the current row, or the insert row. The
updateXXX() methods do not update the underlying database, instead the
updateRow() or insertRow() methods are called to update the database. |
public void updateTime(String columnName,
Time x) throws SQLException {
updateTime(findColumn(columnName), x);
}
JDBC 2.0 Update a column with a Time value. The updateXXX() methods are
used to update column values in the current row, or the insert row. The
updateXXX() methods do not update the underlying database, instead the
updateRow() or insertRow() methods are called to update the database. |
public void updateTimestamp(int columnIndex,
Timestamp x) throws SQLException {
throw new NotUpdatable();
}
JDBC 2.0 Update a column with a Timestamp value. The updateXXX() methods
are used to update column values in the current row, or the insert row.
The updateXXX() methods do not update the underlying database, instead
the updateRow() or insertRow() methods are called to update the database. |
public void updateTimestamp(String columnName,
Timestamp x) throws SQLException {
updateTimestamp(findColumn(columnName), x);
}
JDBC 2.0 Update a column with a Timestamp value. The updateXXX() methods
are used to update column values in the current row, or the insert row.
The updateXXX() methods do not update the underlying database, instead
the updateRow() or insertRow() methods are called to update the database. |
public boolean wasNull() throws SQLException {
return this.wasNullFlag;
}
A column may have the value of SQL NULL; wasNull() reports whether the
last column read had this special value. Note that you must first call
getXXX on a column to try to read its value and then call wasNull() to
find if the value was SQL NULL |