JDBCResultSet.java 文件源码

java
阅读 30 收藏 0 点赞 0 评论 0

项目:dev-courses 作者:
/**
 * <!-- start generic documentation -->
 * Retrieves the value of the designated column in the current row
 * of this <code>ResultSet</code> object as a
 * <code>java.io.Reader</code> object.
 * <!-- end generic documentation -->
 *
 * <!-- start release-specific documentation -->
 * <div class="ReleaseSpecificDocumentation">
 * <h3>HSQLDB-Specific Information:</h3> <p>
 *
 * HSQLDB supports this feature. <p>
 * </div>
 * <!-- end release-specific documentation -->
 *
 * @return a <code>java.io.Reader</code> object that contains the column
 * value; if the value is SQL <code>NULL</code>, the value returned is
 * <code>null</code> in the Java programming language.
 * @param columnIndex the first column is 1, the second is 2, ...
 * @exception SQLException if a database access error occurs or this method is
 *            called on a closed result set
 * @since JDK 1.2
 */
public java.io.Reader getCharacterStream(
        int columnIndex) throws SQLException {

    checkColumn(columnIndex);

    Type   sourceType = resultMetaData.columnTypes[columnIndex - 1];
    Object o          = getColumnInType(columnIndex, sourceType);

    if (o == null) {
        return null;
    }

    if (o instanceof ClobDataID) {
        return ((ClobDataID) o).getCharacterStream(session);
    } else if (o instanceof Clob) {
        return ((Clob) o).getCharacterStream();
    } else if (o instanceof String) {
        return new StringReader((String) o);
    }

    throw JDBCUtil.sqlException(ErrorCode.X_42561);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号