Object value; // sanity check. checkIndex(columnIndex); // make sure the cursor is on a valid row checkCursor(); setLastValueNull(false); value = getCurrentRow().getColumnObject(columnIndex); // check for SQL NULL if (value == null) { setLastValueNull(true); return (double)0; } try { return ((new Double(value.toString().trim())).doubleValue()); } catch (NumberFormatException ex) { throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.doublefail").toString(), new Object[] {value.toString().trim(), columnIndex})); } } /** * Retrieves the value of the designated column in the current row * of this <code>CachedRowSetImpl</code> object as a * <code>java.math.BigDecimal</code> object. * <P> * This method is deprecated; use the version of <code>getBigDecimal</code> * that does not take a scale parameter and returns a value with full * precision. * * @param columnIndex the first column is <code>1</code>, the second * is <code>2</code>, and so on; must be <code>1</code> or larger * and equal to or less than the number of columns in the rowset * @param scale the number of digits to the right of the decimal point in the * value returned * @return the column value with the specified number of digits to the right * of the decimal point; if the value is SQL <code>NULL</code>, the * result is <code>null</code> * @throws SQLException if the given column index is out of bounds, * the cursor is not on a valid row, or this method fails * @deprecated */ public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { Object value; BigDecimal bDecimal, retVal; // sanity check. checkIndex(columnIndex); // make sure the cursor is on a valid row checkCursor(); setLastValueNull(false); value = getCurrentRow().getColumnObject(columnIndex); // check for SQL NULL if (value == null) { setLastValueNull(true); return (new BigDecimal(0)); } bDecimal = this.getBigDecimal(columnIndex); retVal = bDecimal.setScale(scale); return retVal; } /** * Retrieves the value of the designated column in the current row * of this <code>CachedRowSetImpl</code> object as a * <code>byte</code> array value. * * @param columnIndex the first column is <code>1</code>, the second * is <code>2</code>, and so on; must be <code>1</code> or larger * and equal to or less than the number of columns in the rowset * @return the column value as a <code>byte</code> array in the Java programming * language; if the value is SQL <code>NULL</code>, the * result is <code>null</code> * * @throws SQLException if (1) the given column index is out of bounds, * (2) the cursor is not on one of this rowset's rows or its * insert row, or (3) the designated column does not store an * SQL <code><b>BINARY</b>, <b>VARBINARY</b> or * LONGVARBINARY</code> value. * The bold SQL type designates the recommended return type. * @see #getBytes(String) */ public byte[] getBytes(int columnIndex) throws SQLException { // sanity check. checkIndex(columnIndex); // make sure the cursor is on a valid row checkCursor(); if (isBinary(RowSetMD.getColumnType(columnIndex)) == false) { throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString()); } return (byte[])(getCurrentRow().getColumnObject(columnIndex)); } /** * Retrieves the value of the designated column in the current row * of this <code>CachedRowSetImpl</code> object as a * <code>java.sql.Date</code> object. * * @param columnIndex the first column is <code>1</code>, the second * is <code>2</code>, and so on; must be <code>1</code> or larger * and equal to or less than the number of columns in the rowset * @return the column value as a <code>java.sql.Data</code> object; if * the value is SQL <code>NULL</code>, the * result is <code>null</code> * @throws SQLException if the given column index is out of bounds, * the cursor is not on a valid row, or this method fails */ public java.sql.Date getDate(int columnIndex) throws SQLException { Object value; // sanity check. checkIndex(columnIndex); // make sure the cursor is on a valid row checkCursor(); setLastValueNull(false); value = getCurrentRow().getColumnObject(columnIndex); // check for SQL NULL if (value == null) { setLastValueNull(true); return null; } /* * The object coming back from the db could be * a date, a timestamp, or a char field variety. * If it's a date type return it, a timestamp * we turn into a long and then into a date, * char strings we try to parse. Yuck. */ switch (RowSetMD.getColumnType(columnIndex)) { case java.sql.Types.DATE: { long sec = ((java.sql.Date)value).getTime(); return new java.sql.Date(sec); } case java.sql.Types.TIMESTAMP: { long sec = ((java.sql.Timestamp)value).getTime(); return new java.sql.Date(sec); } case java.sql.Types.CHAR: case java.sql.Types.VARCHAR: case java.sql.Types.LONGVARCHAR: { try { DateFormat df = DateFormat.getDateInstance(); return ((java.sql.Date)(df.parse(value.toString()))); } catch (ParseException ex) { throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.datefail").toString(), new Object[] {value.toString().trim(), columnIndex})); } } default: { throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.datefail").toString(), new Object[] {value.toString().trim(), columnIndex})); } } } /** * Retrieves the value of the designated column in the current row * of this <code>CachedRowSetImpl</code> object as a * <code>java.sql.Time</code> object. * * @param columnIndex the first column is <code>1</code>, the second * is <code>2</code>, and so on; must be <code>1</code> or larger * and equal to or less than the number of columns in the rowset * @return the column value; if the value is SQL <code>NULL</code>, the * result is <code>null</code> * @throws SQLException if the given column index is out of bounds, * the cursor is not on a valid row, or this method fails */ public java.sql.Time getTime(int columnIndex) throws SQLException { Object value; // sanity check. checkIndex(columnIndex); // make sure the cursor is on a valid row checkCursor(); setLastValueNull(false); value = getCurrentRow().getColumnObject(columnIndex); // check for SQL NULL if (value == null) { setLastValueNull(true); return null; } /* * The object coming back from the db could be * a date, a timestamp, or a char field variety. * If it's a date type return it, a timestamp * we turn into a long and then into a date, * char strings we try to parse. Yuck. */ switch (RowSetMD.getColumnType(columnIndex)) { case java.sql.Types.TIME: { return (java.sql.Time)value; } case java.sql.Types.TIMESTAMP: { long sec = ((java.sql.Timestamp)value).getTime(); return new java.sql.Time(sec); } case java.sql.Types.CHAR: case java.sql.Types.VARCHAR: case java.sql.Types.LONGVARCHAR: { try { DateFormat tf = DateFormat.getTimeInstance(); return ((java.sql.Time)(tf.parse(value.toString()))); } catch (ParseException ex) { throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.timefail").toString(), new Object[] {value.toString().trim(), columnIndex})); } } default: { throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.timefail").toString(), new Object[] {value.toString().trim(), columnIndex})); } } } /** * Retrieves the value of the designated column in the current row * of this <code>CachedRowSetImpl</code> object as a * <code>java.sql.Timestamp</code> object. * * @param columnIndex the first column is <code>1</code>, the second * is <code>2</code>, and so on; must be <code>1</code> or larger * and equal to or less than the number of columns in the rowset * @return the column value; if the value is SQL <code>NULL</code>, the * result is <code>null</code> * @throws SQLException if the given column index is out of bounds, * the cursor is not on a valid row, or this method fails */ public java.sql.Timestamp getTimestamp(int columnIndex) throws SQLException { Object value; // sanity check. checkIndex(columnIndex); // make sure the cursor is on a valid row checkCursor(); setLastValueNull(false); value = getCurrentRow().getColumnObject(columnIndex); // check for SQL NULL if (value == null) { setLastValueNull(true); return null; } /* * The object coming back from the db could be * a date, a timestamp, or a char field variety. * If it's a date type return it; a timestamp * we turn into a long and then into a date; * char strings we try to parse. Yuck. */ switch (RowSetMD.getColumnType(columnIndex)) { case java.sql.Types.TIMESTAMP: { return (java.sql.Timestamp)value; } case java.sql.Types.TIME: { long sec = ((java.sql.Time)value).getTime(); return new java.sql.Timestamp(sec); } case java.sql.Types.DATE: { long sec = ((java.sql.Date)value).getTime(); return new java.sql.Timestamp(sec); } case java.sql.Types.CHAR: case java.sql.Types.VARCHAR: case java.sql.Types.LONGVARCHAR: { try { DateFormat tf = DateFormat.getTimeInstance(); return ((java.sql.Timestamp)(tf.parse(value.toString()))); } catch (ParseException ex) { throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.timefail").toString(), new Object[] {value.toString().trim(), columnIndex})); } } default: { throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.timefail").toString(), new Object[] {value.toString().trim(), columnIndex})); } } } /** * Retrieves the value of the designated column in the current row of this * <code>CachedRowSetImpl</code> object as a <code>java.io.InputStream</code> * object. * * A column value can be retrieved as a stream of ASCII characters * and then read in chunks from the stream. This method is particularly * suitable for retrieving large <code>LONGVARCHAR</code> values. The JDBC * driver will do any necessary conversion from the database format into ASCII. * * <P><B>Note:</B> 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 <code>0</code> for <code>CachedRowSetImpl.available()</code> * whether there is data available or not. * * @param columnIndex the first column is <code>1</code>, the second * is <code>2</code>, and so on; must be <code>1</code> or larger * and equal to or less than the number of columns in this rowset * @return a Java input stream that delivers the database column value * as a stream of one-byte ASCII characters. If the value is SQL * <code>NULL</code>, the result is <code>null</code>. * @throws SQLException if (1) the given column index is out of bounds, * (2) the cursor is not on one of this rowset's rows or its * insert row, or (3) the designated column does not store an * SQL <code>CHAR, VARCHAR</code>, <code><b>LONGVARCHAR</b></code> * <code>BINARY, VARBINARY</code> or <code>LONGVARBINARY</code> value. The * bold SQL type designates the recommended return types that this method is * used to retrieve. * @see #getAsciiStream(String) */ public java.io.InputStream getAsciiStream(int columnIndex) throws SQLException { Object value; // always free an old stream asciiStream = null; // sanity check checkIndex(columnIndex); //make sure the cursor is on a vlid row checkCursor(); value = getCurrentRow().getColumnObject(columnIndex); if (value == null) { lastValueNull = true; return null; } try { if (isString(RowSetMD.getColumnType(columnIndex))) { asciiStream = new ByteArrayInputStream(((String)value).getBytes("ASCII")); } else { throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString()); } } catch (java.io.UnsupportedEncodingException ex) { throw new SQLException(ex.getMessage()); } return (java.io.InputStream)asciiStream; } /** * A column value can be retrieved as a stream of Unicode characters * and then read in chunks from the stream. This method is particularly * suitable for retrieving large LONGVARCHAR values. The JDBC driver will * do any necessary conversion from the database format into Unicode. * * <P><B>Note:</B> 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. * * @param columnIndex the first column is <code>1</code>, the second * is <code>2</code>, and so on; must be <code>1</code> or larger * and equal to or less than the number of columns in this rowset * @return a Java input stream that delivers the database column value * as a stream of two byte Unicode characters. If the value is SQL NULL * then the result is null. * @throws SQLException if an error occurs * @deprecated */ public java.io.InputStream getUnicodeStream(int columnIndex) throws SQLException { // always free an old stream unicodeStream = null; // sanity check. checkIndex(columnIndex); // make sure the cursor is on a valid row checkCursor(); if (isBinary(RowSetMD.getColumnType(columnIndex)) == false && isString(RowSetMD.getColumnType(columnIndex)) == false) { throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString()); } Object value = getCurrentRow().getColumnObject(columnIndex); if (value == null) { lastValueNull = true; return null; } unicodeStream = new StringBufferInputStream(value.toString()); return (java.io.InputStream)unicodeStream; } /** * Retrieves the value of the designated column in the current row of this * <code>CachedRowSetImpl</code> object as a <code>java.io.InputStream</code> * object. * <P> * A column value can be retrieved as a stream of uninterpreted bytes * and then read in chunks from the stream. This method is particularly * suitable for retrieving large <code>LONGVARBINARY</code> values. * * <P><B>Note:</B> 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 <code>0</code> for * <code>CachedRowSetImpl.available()</code> whether there is data * available or not. * * @param columnIndex the first column is <code>1</code>, the second * is <code>2</code>, and so on; must be <code>1</code> or larger * and equal to or less than the number of columns in the rowset * @return a Java input stream that delivers the database column value * as a stream of uninterpreted bytes. If the value is SQL <code>NULL</code> * then the result is <code>null</code>. * @throws SQLException if (1) the given column index is out of bounds, * (2) the cursor is not on one of this rowset's rows or its * insert row, or (3) the designated column does not store an * SQL <code>BINARY, VARBINARY</code> or <code><b>LONGVARBINARY</b></code> * The bold type indicates the SQL type that this method is recommened * to retrieve. * @see #getBinaryStream(String) */ public java.io.InputStream getBinaryStream(int columnIndex) throws SQLException { // always free an old stream binaryStream = null; // sanity check. checkIndex(columnIndex); // make sure the cursor is on a valid row checkCursor(); if (isBinary(RowSetMD.getColumnType(columnIndex)) == false) { throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString()); } Object value = getCurrentRow().getColumnObject(columnIndex); if (value == null) { lastValueNull = true; return null; } binaryStream = new ByteArrayInputStream((byte[])value); return (java.io.InputStream)binaryStream; } // Methods for accessing results by column name /** * Retrieves the value stored in the designated column * of the current row as a <code>String</code> object. * * @param columnName a <code>String</code> object giving the SQL name of * a column in this <code>CachedRowSetImpl</code> object * @return the column value; if the value is SQL <code>NULL</code>, * the result is <code>null</code> * @throws SQLException if (1) the given column name is not the name of * a column in this rowset, (2) the cursor is not on one of * this rowset's rows or its insert row, or (3) the designated * column does not store an SQL <code>TINYINT, SMALLINT, INTEGER * BIGINT, REAL, FLOAT, DOUBLE, DECIMAL, NUMERIC, BIT, <b>CHAR</b>, * <b>VARCHAR</b></code> or <code>LONGVARCHAR<</code> value. The bold SQL type * designates the recommended return type. */ public String getString(String columnName) throws SQLException { return getString(getColIdxByName(columnName)); } /** * Retrieves the value stored in the designated column * of the current row as a <code>boolean</code> value. * * @param columnName a <code>String</code> object giving the SQL name of * a column in this <code>CachedRowSetImpl</code> object * @return the column value as a <code>boolean</code> in the Java programming * language; if the value is SQL <code>NULL</code>, * the result is <code>false</code> * @throws SQLException if (1) the given column name is not the name of * a column in this rowset, (2) the cursor is not on one of * this rowset's rows or its insert row, or (3) the designated * column does not store an SQL <code>BOOLEAN</code> value * @see #getBoolean(int) */ public boolean getBoolean(String columnName) throws SQLException { return getBoolean(getColIdxByName(columnName));Lines 2001–2500 of 10133. Previous lines Load more
Object value; // sanity check. checkIndex(columnIndex); // make sure the cursor is on a valid row checkCursor(); setLastValueNull(false); value = getCurrentRow().getColumnObject(columnIndex); // check for SQL NULL if (value == null) { setLastValueNull(true); return (double)0; } try { return ((new Double(value.toString().trim())).doubleValue()); } catch (NumberFormatException ex) { throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.doublefail").toString(), new Object[] {value.toString().trim(), columnIndex})); } } /** * Retrieves the value of the designated column in the current row * of this <code>CachedRowSetImpl</code> object as a * <code>java.math.BigDecimal</code> object. * <P> * This method is deprecated; use the version of <code>getBigDecimal</code> * that does not take a scale parameter and returns a value with full * precision. * * @param columnIndex the first column is <code>1</code>, the second * is <code>2</code>, and so on; must be <code>1</code> or larger * and equal to or less than the number of columns in the rowset * @param scale the number of digits to the right of the decimal point in the * value returned * @return the column value with the specified number of digits to the right * of the decimal point; if the value is SQL <code>NULL</code>, the * result is <code>null</code> * @throws SQLException if the given column index is out of bounds, * the cursor is not on a valid row, or this method fails * @deprecated */ public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { Object value; BigDecimal bDecimal, retVal; // sanity check. checkIndex(columnIndex); // make sure the cursor is on a valid row checkCursor(); setLastValueNull(false); value = getCurrentRow().getColumnObject(columnIndex); // check for SQL NULL if (value == null) { setLastValueNull(true); return (new BigDecimal(0)); } bDecimal = this.getBigDecimal(columnIndex); retVal = bDecimal.setScale(scale); return retVal; } /** * Retrieves the value of the designated column in the current row * of this <code>CachedRowSetImpl</code> object as a * <code>byte</code> array value. * * @param columnIndex the first column is <code>1</code>, the second * is <code>2</code>, and so on; must be <code>1</code> or larger * and equal to or less than the number of columns in the rowset * @return the column value as a <code>byte</code> array in the Java programming * language; if the value is SQL <code>NULL</code>, the * result is <code>null</code> * * @throws SQLException if (1) the given column index is out of bounds, * (2) the cursor is not on one of this rowset's rows or its * insert row, or (3) the designated column does not store an * SQL <code><b>BINARY</b>, <b>VARBINARY</b> or * LONGVARBINARY</code> value. * The bold SQL type designates the recommended return type. * @see #getBytes(String) */ public byte[] getBytes(int columnIndex) throws SQLException { // sanity check. checkIndex(columnIndex); // make sure the cursor is on a valid row checkCursor(); if (isBinary(RowSetMD.getColumnType(columnIndex)) == false) { throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString()); } return (byte[])(getCurrentRow().getColumnObject(columnIndex)); } /** * Retrieves the value of the designated column in the current row * of this <code>CachedRowSetImpl</code> object as a * <code>java.sql.Date</code> object. * * @param columnIndex the first column is <code>1</code>, the second * is <code>2</code>, and so on; must be <code>1</code> or larger * and equal to or less than the number of columns in the rowset * @return the column value as a <code>java.sql.Data</code> object; if * the value is SQL <code>NULL</code>, the * result is <code>null</code> * @throws SQLException if the given column index is out of bounds, * the cursor is not on a valid row, or this method fails */ public java.sql.Date getDate(int columnIndex) throws SQLException { Object value; // sanity check. checkIndex(columnIndex); // make sure the cursor is on a valid row checkCursor(); setLastValueNull(false); value = getCurrentRow().getColumnObject(columnIndex); // check for SQL NULL if (value == null) { setLastValueNull(true); return null; } /* * The object coming back from the db could be * a date, a timestamp, or a char field variety. * If it's a date type return it, a timestamp * we turn into a long and then into a date, * char strings we try to parse. Yuck. */ switch (RowSetMD.getColumnType(columnIndex)) { case java.sql.Types.DATE: { long sec = ((java.sql.Date)value).getTime(); return new java.sql.Date(sec); } case java.sql.Types.TIMESTAMP: { long sec = ((java.sql.Timestamp)value).getTime(); return new java.sql.Date(sec); } case java.sql.Types.CHAR: case java.sql.Types.VARCHAR: case java.sql.Types.LONGVARCHAR: { try { DateFormat df = DateFormat.getDateInstance(); return ((java.sql.Date)(df.parse(value.toString()))); } catch (ParseException ex) { throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.datefail").toString(), new Object[] {value.toString().trim(), columnIndex})); } } default: { throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.datefail").toString(), new Object[] {value.toString().trim(), columnIndex})); } } } /** * Retrieves the value of the designated column in the current row * of this <code>CachedRowSetImpl</code> object as a * <code>java.sql.Time</code> object. * * @param columnIndex the first column is <code>1</code>, the second * is <code>2</code>, and so on; must be <code>1</code> or larger * and equal to or less than the number of columns in the rowset * @return the column value; if the value is SQL <code>NULL</code>, the * result is <code>null</code> * @throws SQLException if the given column index is out of bounds, * the cursor is not on a valid row, or this method fails */ public java.sql.Time getTime(int columnIndex) throws SQLException { Object value; // sanity check. checkIndex(columnIndex); // make sure the cursor is on a valid row checkCursor(); setLastValueNull(false); value = getCurrentRow().getColumnObject(columnIndex); // check for SQL NULL if (value == null) { setLastValueNull(true); return null; } /* * The object coming back from the db could be * a date, a timestamp, or a char field variety. * If it's a date type return it, a timestamp * we turn into a long and then into a date, * char strings we try to parse. Yuck. */ switch (RowSetMD.getColumnType(columnIndex)) { case java.sql.Types.TIME: { return (java.sql.Time)value; } case java.sql.Types.TIMESTAMP: { long sec = ((java.sql.Timestamp)value).getTime(); return new java.sql.Time(sec); } case java.sql.Types.CHAR: case java.sql.Types.VARCHAR: case java.sql.Types.LONGVARCHAR: { try { DateFormat tf = DateFormat.getTimeInstance(); return ((java.sql.Time)(tf.parse(value.toString()))); } catch (ParseException ex) { throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.timefail").toString(), new Object[] {value.toString().trim(), columnIndex})); } } default: { throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.timefail").toString(), new Object[] {value.toString().trim(), columnIndex})); } } } /** * Retrieves the value of the designated column in the current row * of this <code>CachedRowSetImpl</code> object as a * <code>java.sql.Timestamp</code> object. * * @param columnIndex the first column is <code>1</code>, the second * is <code>2</code>, and so on; must be <code>1</code> or larger * and equal to or less than the number of columns in the rowset * @return the column value; if the value is SQL <code>NULL</code>, the * result is <code>null</code> * @throws SQLException if the given column index is out of bounds, * the cursor is not on a valid row, or this method fails */ public java.sql.Timestamp getTimestamp(int columnIndex) throws SQLException { Object value; // sanity check. checkIndex(columnIndex); // make sure the cursor is on a valid row checkCursor(); setLastValueNull(false); value = getCurrentRow().getColumnObject(columnIndex); // check for SQL NULL if (value == null) { setLastValueNull(true); return null; } /* * The object coming back from the db could be * a date, a timestamp, or a char field variety. * If it's a date type return it; a timestamp * we turn into a long and then into a date; * char strings we try to parse. Yuck. */ switch (RowSetMD.getColumnType(columnIndex)) { case java.sql.Types.TIMESTAMP: { return (java.sql.Timestamp)value; } case java.sql.Types.TIME: { long sec = ((java.sql.Time)value).getTime(); return new java.sql.Timestamp(sec); } case java.sql.Types.DATE: { long sec = ((java.sql.Date)value).getTime(); return new java.sql.Timestamp(sec); } case java.sql.Types.CHAR: case java.sql.Types.VARCHAR: case java.sql.Types.LONGVARCHAR: { try { DateFormat tf = DateFormat.getTimeInstance(); return ((java.sql.Timestamp)(tf.parse(value.toString()))); } catch (ParseException ex) { throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.timefail").toString(), new Object[] {value.toString().trim(), columnIndex})); } } default: { throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.timefail").toString(), new Object[] {value.toString().trim(), columnIndex})); } } } /** * Retrieves the value of the designated column in the current row of this * <code>CachedRowSetImpl</code> object as a <code>java.io.InputStream</code> * object. * * A column value can be retrieved as a stream of ASCII characters * and then read in chunks from the stream. This method is particularly * suitable for retrieving large <code>LONGVARCHAR</code> values. The JDBC * driver will do any necessary conversion from the database format into ASCII. * * <P><B>Note:</B> 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 <code>0</code> for <code>CachedRowSetImpl.available()</code> * whether there is data available or not. * * @param columnIndex the first column is <code>1</code>, the second * is <code>2</code>, and so on; must be <code>1</code> or larger * and equal to or less than the number of columns in this rowset * @return a Java input stream that delivers the database column value * as a stream of one-byte ASCII characters. If the value is SQL * <code>NULL</code>, the result is <code>null</code>. * @throws SQLException if (1) the given column index is out of bounds, * (2) the cursor is not on one of this rowset's rows or its * insert row, or (3) the designated column does not store an * SQL <code>CHAR, VARCHAR</code>, <code><b>LONGVARCHAR</b></code> * <code>BINARY, VARBINARY</code> or <code>LONGVARBINARY</code> value. The * bold SQL type designates the recommended return types that this method is * used to retrieve. * @see #getAsciiStream(String) */ public java.io.InputStream getAsciiStream(int columnIndex) throws SQLException { Object value; // always free an old stream asciiStream = null; // sanity check checkIndex(columnIndex); //make sure the cursor is on a vlid row checkCursor(); value = getCurrentRow().getColumnObject(columnIndex); if (value == null) { lastValueNull = true; return null; } try { if (isString(RowSetMD.getColumnType(columnIndex))) { asciiStream = new ByteArrayInputStream(((String)value).getBytes("ASCII")); } else { throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString()); } } catch (java.io.UnsupportedEncodingException ex) { throw new SQLException(ex.getMessage()); } return (java.io.InputStream)asciiStream; } /** * A column value can be retrieved as a stream of Unicode characters * and then read in chunks from the stream. This method is particularly * suitable for retrieving large LONGVARCHAR values. The JDBC driver will * do any necessary conversion from the database format into Unicode. * * <P><B>Note:</B> 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. * * @param columnIndex the first column is <code>1</code>, the second * is <code>2</code>, and so on; must be <code>1</code> or larger * and equal to or less than the number of columns in this rowset * @return a Java input stream that delivers the database column value * as a stream of two byte Unicode characters. If the value is SQL NULL * then the result is null. * @throws SQLException if an error occurs * @deprecated */ public java.io.InputStream getUnicodeStream(int columnIndex) throws SQLException { // always free an old stream unicodeStream = null; // sanity check. checkIndex(columnIndex); // make sure the cursor is on a valid row checkCursor(); if (isBinary(RowSetMD.getColumnType(columnIndex)) == false && isString(RowSetMD.getColumnType(columnIndex)) == false) { throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString()); } Object value = getCurrentRow().getColumnObject(columnIndex); if (value == null) { lastValueNull = true; return null; } unicodeStream = new StringBufferInputStream(value.toString()); return (java.io.InputStream)unicodeStream; } /** * Retrieves the value of the designated column in the current row of this * <code>CachedRowSetImpl</code> object as a <code>java.io.InputStream</code> * object. * <P> * A column value can be retrieved as a stream of uninterpreted bytes * and then read in chunks from the stream. This method is particularly * suitable for retrieving large <code>LONGVARBINARY</code> values. * * <P><B>Note:</B> 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 <code>0</code> for * <code>CachedRowSetImpl.available()</code> whether there is data * available or not. * * @param columnIndex the first column is <code>1</code>, the second * is <code>2</code>, and so on; must be <code>1</code> or larger * and equal to or less than the number of columns in the rowset * @return a Java input stream that delivers the database column value * as a stream of uninterpreted bytes. If the value is SQL <code>NULL</code> * then the result is <code>null</code>. * @throws SQLException if (1) the given column index is out of bounds, * (2) the cursor is not on one of this rowset's rows or its * insert row, or (3) the designated column does not store an * SQL <code>BINARY, VARBINARY</code> or <code><b>LONGVARBINARY</b></code> * The bold type indicates the SQL type that this method is recommened * to retrieve. * @see #getBinaryStream(String) */ public java.io.InputStream getBinaryStream(int columnIndex) throws SQLException { // always free an old stream binaryStream = null; // sanity check. checkIndex(columnIndex); // make sure the cursor is on a valid row checkCursor(); if (isBinary(RowSetMD.getColumnType(columnIndex)) == false) { throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString()); } Object value = getCurrentRow().getColumnObject(columnIndex); if (value == null) { lastValueNull = true; return null; } binaryStream = new ByteArrayInputStream((byte[])value); return (java.io.InputStream)binaryStream; } // Methods for accessing results by column name /** * Retrieves the value stored in the designated column * of the current row as a <code>String</code> object. * * @param columnName a <code>String</code> object giving the SQL name of * a column in this <code>CachedRowSetImpl</code> object * @return the column value; if the value is SQL <code>NULL</code>, * the result is <code>null</code> * @throws SQLException if (1) the given column name is not the name of * a column in this rowset, (2) the cursor is not on one of * this rowset's rows or its insert row, or (3) the designated * column does not store an SQL <code>TINYINT, SMALLINT, INTEGER * BIGINT, REAL, FLOAT, DOUBLE, DECIMAL, NUMERIC, BIT, <b>CHAR</b>, * <b>VARCHAR</b></code> or <code>LONGVARCHAR<</code> value. The bold SQL type * designates the recommended return type. */ public String getString(String columnName) throws SQLException { return getString(getColIdxByName(columnName)); } /** * Retrieves the value stored in the designated column * of the current row as a <code>boolean</code> value. * * @param columnName a <code>String</code> object giving the SQL name of * a column in this <code>CachedRowSetImpl</code> object * @return the column value as a <code>boolean</code> in the Java programming * language; if the value is SQL <code>NULL</code>, * the result is <code>false</code> * @throws SQLException if (1) the given column name is not the name of * a column in this rowset, (2) the cursor is not on one of * this rowset's rows or its insert row, or (3) the designated * column does not store an SQL <code>BOOLEAN</code> value * @see #getBoolean(int) */ public boolean getBoolean(String columnName) throws SQLException { return getBoolean(getColIdxByName(columnName));