⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jdbcresultset.java

📁 Java写的含有一个jdbc驱动的小型数据库数据库引擎
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	return getBoolean(findColumn(columnName));
    }

    /**
     * Gets the value of a column in the current row as a Java byte.
     *
     * @param columnName the SQL name of the column
     * @return the column value; if the value is SQL NULL, the result is 0
     * @exception SQLException if a database access error occurs
     */
    public byte getByte(String columnName) throws SQLException {
	return getByte(findColumn(columnName));
    }

    /**
     * Gets the value of a column in the current row as a Java short.
     *
     * @param columnName the SQL name of the column
     * @return the column value; if the value is SQL NULL, the result is 0
     * @exception SQLException if a database access error occurs
     */
    public short getShort(String columnName) throws SQLException {
	return getShort(findColumn(columnName));
    }

    /**
     * Gets the value of a column in the current row as a Java int.
     *
     * @param columnName the SQL name of the column
     * @return the column value; if the value is SQL NULL, the result is 0
     * @exception SQLException if a database access error occurs
     */
    public int getInt(String columnName) throws SQLException {
	return getInt(findColumn(columnName));
    }

    /**
     * Gets the value of a column in the current row as a Java long.
     *
     * @param columnName the SQL name of the column
     * @return the column value; if the value is SQL NULL, the result is 0
     * @exception SQLException if a database access error occurs
     */
    public long getLong(String columnName) throws SQLException {
	return getLong(findColumn(columnName));
    }

    /**
     * Gets the value of a column in the current row as a Java float.
     *
     * @param columnName the SQL name of the column
     * @return the column value; if the value is SQL NULL, the result is 0
     * @exception SQLException if a database access error occurs
     */
    public float getFloat(String columnName) throws SQLException {
	return getFloat(findColumn(columnName));
    }

    /**
     * Gets the value of a column in the current row as a Java double.
     *
     * @param columnName the SQL name of the column
     * @return the column value; if the value is SQL NULL, the result is 0
     * @exception SQLException if a database access error occurs
     */
    public double getDouble(String columnName) throws SQLException {
	return getDouble(findColumn(columnName));
    }

    /**
     * Gets the value of a column in the current row as a java.math.BigDecimal
     * object.
     *
     * @param columnName the SQL name of the column
     * @param scale the number of digits to the right of the decimal
     * @return the column value; if the value is SQL NULL, the result is null
     * @exception SQLException if a database access error occurs
     * @deprecated
     */
    public BigDecimal getBigDecimal(String columnName,
				    int scale) throws SQLException {
	return getBigDecimal(findColumn(columnName), scale);
    }

    /**
     * Gets the value of a column in the current row as a Java byte array.
     * The bytes represent the raw values returned by the driver.
     *
     * @param columnName the SQL name of the column
     * @return the column value; if the value is SQL NULL, the result is null
     * @exception SQLException if a database access error occurs
     */
    public byte[] getBytes(String columnName) throws SQLException {
	return getBytes(findColumn(columnName));
    }

    /**
     * Gets the value of a column in the current row as a java.sql.Date object.
     *
     * @param columnName the SQL name of the column
     * @return the column value; if the value is SQL NULL, the result is null
     * @exception SQLException if a database access error occurs
     */
    public java.sql.Date getDate(String columnName) throws SQLException {
	return getDate(findColumn(columnName));
    }

    /**
     * Gets the value of a column in the current row as a java.sql.Time object.
     *
     * @param columnName the SQL name of the column
     * @return the column value; if the value is SQL NULL, the result is null
     * @exception SQLException if a database access error occurs
     */
    public Time getTime(String columnName) throws SQLException {
	return getTime(findColumn(columnName));
    }

    /**
     * Gets the value of a column in the current row as a java.sql.Timestamp
     * object.
     *
     * @param columnName the SQL name of the column
     * @return the column value; if the value is SQL NULL, the result is null
     * @exception SQLException if a database access error occurs
     */
    public Timestamp getTimestamp(String columnName) throws SQLException {
	return getTimestamp(findColumn(columnName));
    }

    /**
     * Gets the value of a column in the current row as a stream of
     * ASCII characters. The value can then be 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 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 0 when the method <code>available</code>
     * is called whether there is data
     * available or not.
     *
     * @param columnName the SQL name of the column
     * @return a Java input stream that delivers the database column value
     * as a stream of one byte ASCII characters.  If the value is SQL NULL
     * then the result is null.
     * @exception SQLException if a database access error occurs
     */
    public InputStream getAsciiStream(String columnName) throws SQLException {
	return getAsciiStream(findColumn(columnName));
    }

    /**
     * Gets the value of a column in the current row as a stream of
     * Unicode characters. The value can then be 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.
     * The byte format of the Unicode stream must be Java UTF-8,
     * as defined in the Java Virtual Machine Specification.
     *
     * <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 when the method <code>available</code>
     * is called whether there is data
     * available or not.
     *
     * @param columnName the SQL name of the column
     * @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.
     * @exception SQLException if a database access error occurs
     * @deprecated
     */
    public InputStream getUnicodeStream(String columnName)
	    throws SQLException {
	return getUnicodeStream(findColumn(columnName));
    }

    /**
     * Gets the value of a column in the current row as a stream of
     * uninterpreted bytes. The value can then be read in chunks from the
     * stream. This method is particularly
     * suitable for retrieving large LONGVARBINARY values.  The JDBC driver will
     * do any necessary conversion from the database format into uninterpreted
     * bytes.
     *
     * <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 when the method <code>available</code>
     * is called whether there is data
     * available or not.
     *
     * @param columnName the SQL name of the column
     * @return a Java input stream that delivers the database column value
     * as a stream of uninterpreted bytes.  If the value is SQL NULL
     * then the result is null.
     * @exception SQLException if a database access error occurs
     */
    public InputStream getBinaryStream(String columnName)
	    throws SQLException {
	return getBinaryStream(findColumn(columnName));
    }

    /**
     * <p>The first warning reported by calls on this ResultSet is
     * returned. Subsequent ResultSet warnings will be chained to this
     * SQLWarning.
     *
     * <P>The warning chain is automatically cleared each time a new
     * row is read.
     *
     * <P><B>Note:</B> This warning chain only covers warnings caused
     * by ResultSet methods.  Any warning caused by statement methods
     * (such as reading OUT parameters) will be chained on the
     * Statement object.
     * <P><font color="#009900">
     * HSQL Database Engine never produces warnings and returns always null.
     * </font><P>
     * @return the first SQLWarning or null
     */
    public SQLWarning getWarnings() {
	if (Trace.TRACE) {
	    Trace.trace();
	}

	return null;
    }

    /**
     * After this call getWarnings returns null until a new warning is
     * reported for this ResultSet.
     */
    public void clearWarnings() {
	if (Trace.TRACE) {
	    Trace.trace();
	}
    }

    /**
     * Gets the name of the SQL cursor used by this ResultSet.
     *
     * <P>In SQL, a result table is retrieved through 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. To insure that the cursor has the proper isolation
     * level to support update, the cursor's select statement should be
     * of the form 'select for update'. If the 'for update' clause is
     * omitted the positioned updates may fail.
     *
     * <P>JDBC supports this SQL feature by providing the name of the
     * SQL cursor used by a ResultSet. The current row of a ResultSet
     * is also the current row of this SQL cursor.
     *
     * <P><B>Note:</B> If positioned update is not supported a
     * SQLException is thrown
     *
     * @return the ResultSet's SQL cursor name
     * @exception SQLException if a database access error occurs
     */
    public String getCursorName() throws SQLException {
	if (Trace.TRACE) {
	    Trace.trace();
	}

	throw Trace.error(Trace.FUNCTION_NOT_SUPPORTED);
    }

    /**
     * Retrieves the  number, types and properties of a ResultSet's columns.
     * <P><font color="#009900">
     * HSQL Database Engine implements both the ResultSet and the ResultSetMetaData
     * interface in the class jdbcResultSet, so this function will return the
     * same Object. It is required to call this function to conform the
     * JDBC standard. Other drivers have the ResultSetMetaData in a different
     * class.
     * </font><P>
     * @return the description of a ResultSet's columns
     * @exception SQLException if a database access error occurs
     */
    public ResultSetMetaData getMetaData() throws SQLException {
	return this;
    }

    /**
     * <p>Gets the value of a column in the current row as a Java object.
     *
     * <p>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 for built-in types specified in the JDBC
     * spec.
     *
     * <p>This method may also be used to read datatabase-specific
     * abstract data types.
     *
     * JDBC 2.0
     *
     * In the JDBC 2.0 API, the behavior of method
     * <code>getObject</code> is extended to materialize
     * data of SQL user-defined types.  When the a column contains
     * a structured or distinct value, the behavior of this method is as
     * if it were a call to: getObject(columnIndex,
     * this.getStatement().getConnection().getTypeMap()).
     *
     * @param columnIndex the first column is 1, the second is 2, ...
     * @return a java.lang.Object holding the column value
     * @exception SQLException if a database access error occurs
     */
    public Object getObject(String columnName) throws SQLException {
	return getObject(findColumn(columnName));
    }

    /**
     * <p>Gets the value of a column in the current row as a Java object.
     *
     * <p>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 for built-in types specified in the JDBC
     * spec.
     *
     * <p>This method may also be used to read datatabase-specific
     * abstract data types.
     *
     * JDBC 2.0
     *
     * In the JDBC 2.0 API, the behavior of method
     * <code>getObject</code> is extended to materialize
     * data of SQL user-defined types.  When the a column contains
     * a structured or distinct value, the behavior of this method is as
     * if it were a call to: getObject(columnIndex,
     * this.getStatement().getConnection().getTypeMap()).
     *
     * @param columnName the SQL name of the column
     * @return a java.lang.Object holding the column value.
     * @exception SQLException if a database access error occurs
     */
    public Object getObject(int column) throws SQLException {
	checkColumn(--column);
	checkAvailable();

	Object o = nCurrent.data[column];

	// use checknull because getColumnInType is not used
	checkNull(o);

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

	if (rResult.iType[column] == Column.OTHER) {
	    o = ((ByteArray) o).deserialize();
	} else if (o instanceof ByteArray) {
	    o = ((ByteArray) o).byteValue();
	}

	return o == null ? null : o;
    }

    /**
     * JDBC 2.0
     *
     * <p>Gets the value of a column in the current row as a java.io.Reader.
     * @param columnName the name of the column
     * @return the value in the specified column as a <code>java.io.Reader</code>
     */

//#ifdef JAVA2
    public Reader getCharacterStream(String columnName) throws SQLException {
	return getCharacterStream(findColumn(columnName));
    }

//#endif JAVA2

    /**
     * JDBC 2.0
     *
     * Gets the value of a column in the current row as a java.math.BigDecimal
     * object with full precision.
     *
     * @param columnIndex the first column is 1, the second is 2, ...
     * @return the column value (full precision); if the value is SQL NULL,
     * the result is null
     * @exception SQLException if a database access error occurs
     */

//#ifdef JAVA2
    public BigDecimal getBigDecimal(int column) throws SQLException {
	return getBigDecimal(column, 0);
    }

//#endif JAVA2

    /**
     * JDBC 2.0
     *
     * Gets the value of a column in the current row as a java.math.BigDecimal
     * object with full precision.
     * @param columnName the column name
     * @return the column value (full precision); if the value is SQL NULL,
     * the result is null
     * @exception SQLException if a database access error occurs
     *
     */

//#ifdef JAVA2
    public BigDecimal getBigDecimal(String columnName) throws SQLException {
	return getBigDecimal(findColumn(columnName));
    }

//#endif JAVA2

    /**
     * JDBC 2.0
     *
     * <p>Indicates whether the cursor is before the first row in the result
     * set.
     *
     * @return true if the cursor is before the first row, false otherwise. Returns
     * false when the result set contains no rows.
     */

//#ifdef JAVA2
    public boolean isBeforeFirst() {
	if (Trace.TRACE) {
	    Trace.trace();
	}

	if (bInit == false) {
	    return true;
	}

	return false;
    }

//#endif JAVA2

    /**
     * JDBC 2.0
     *
     * <p>Indicates whether the cursor is after the last row in the result
     * set.
     *
     * @return true if the cursor is  after the last row, false otherwise.
     * Returns false when the result set contains no rows.
     */

//#ifdef JAVA2
    public boolean isAfterLast() {
	if (Trace.TRACE) {
	    Trace.trace();
	}

	if (bInit == false) {
	    return false;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -