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

📄 jdbcresultset.java

📁 纯Java的数据库
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    /**     * <!-- start generic documentation -->     * Retrieves the value of the designated column in the current row     * of this <code>ResultSet</code> object as     * a <code>short</code> in the Java programming language. <p>     * <!-- end generic documentation -->     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return the column value; if the value is SQL <code>NULL</code>, the     * value returned is <code>0</code>     * @exception SQLException if a database access error occurs     */    public short getShort(int columnIndex) throws SQLException {        Object o = getColumnInType(columnIndex, Types.SMALLINT);        return o == null ? 0                         : ((Number) o).shortValue();    }    /**     * <!-- start generic documentation -->     * Retrieves the value of the designated column in the current row     * of this <code>ResultSet</code> object as     * an <code>int</code> in the Java programming language. <p>     * <!-- end generic documentation -->     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return the column value; if the value is SQL <code>NULL</code>, the     * value returned is <code>0</code>     * @exception SQLException if a database access error occurs     */    public int getInt(int columnIndex) throws SQLException {        Object o = getColumnInType(columnIndex, Types.INTEGER);        return o == null ? 0                         : ((Number) o).intValue();    }    /**     * <!-- start generic documentation -->     * Retrieves the value of the designated column in the current row     * of this <code>ResultSet</code> object as     * a <code>long</code> in the Java programming language. <p>     * <!-- end generic documentation -->     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return the column value; if the value is SQL <code>NULL</code>, the     * value returned is <code>0</code>     * @exception SQLException if a database access error occurs     */    public long getLong(int columnIndex) throws SQLException {        Object o = getColumnInType(columnIndex, Types.BIGINT);        return o == null ? 0                         : ((Number) o).longValue();    }    /**     * <!-- start generic documentation -->     * Retrieves the value of the designated column in the current row     * of this <code>ResultSet</code> object as     * a <code>float</code> in the Java programming language. <p>     * <!-- end generic documentation -->     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return the column value; if the value is SQL <code>NULL</code>, the     * value returned is <code>0</code>     * @exception SQLException if a database access error occurs     */    public float getFloat(int columnIndex) throws SQLException {        Object o = getColumnInType(columnIndex, Types.REAL);        return o == null ? (float) 0.0                         : ((Number) o).floatValue();    }    /**     * <!-- start generic documentation -->     * Retrieves the value of the designated column in the current row     * of this <code>ResultSet</code> object as     * a <code>double</code> in the Java programming language. <p>     * <!-- end generic documentation -->     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return the column value; if the value is SQL <code>NULL</code>, the     * value returned is <code>0</code>     * @exception SQLException if a database access error occurs     */    public double getDouble(int columnIndex) throws SQLException {        Object o = getColumnInType(columnIndex, Types.DOUBLE);        return o == null ? 0.0                         : ((Number) o).doubleValue();    }    /**     * <!-- start generic documentation -->     * Retrieves the value of the designated column in the current row     * of this <code>ResultSet</code> object as     * a <code>java.sql.BigDecimal</code> in the Java programming language.<p>     * <!-- end generic documentation -->     *     * <!-- start release-specific documentation -->     * <div class="ReleaseSpecificDocumentation">     * <h3>HSQLDB-Specific Information:</h3> <p>     *     * Beginning with 1.7.0, HSQLDB converts the result and sets the scale     * with BigDecimal.ROUND_HALF_DOWN.     * </div>     * <!-- end release-specific documentation -->     *     * @param columnIndex the first column is 1, the second is 2, ...     * @param scale the number of digits to the right of the decimal point     * @return the column value; if the value is SQL <code>NULL</code>, the     * value returned is <code>null</code>     * @exception SQLException if a database access error occurs     * @deprecated by java.sun.com as of JDK 1.2     *///#ifdef DEPRECATEDJDBC    public BigDecimal getBigDecimal(int columnIndex,                                    int scale) throws SQLException {        // boucherb@users 20020502 - added conversion        BigDecimal bd = (BigDecimal) getColumnInType(columnIndex,            Types.DECIMAL);        if (scale < 0) {            throw Util.sqlException(Trace.INVALID_JDBC_ARGUMENT);        }        if (bd != null) {            bd = bd.setScale(scale, BigDecimal.ROUND_HALF_DOWN);        }        return bd;    }//#endif    /**     * <!-- start generic documentation -->     * Retrieves the value of the designated column in the current row     * of this <code>ResultSet</code> object as     * a <code>byte</code> array in the Java programming language.     * The bytes represent the raw values returned by the driver. <p>     * <!-- end generic documentation -->     *     * <!-- start release-specific documentation -->     * <div class="ReleaseSpecificDocumentation">     * <h3>HSQLDB-Specific Information:</h3> <p>     *     * HSQLDB returns correct values for columns of type <code>BINARY</code>,     * <code>CHAR</code> and their variations. For other types, it returns     * the <code>byte[]</code> for the <code>String</code> representation     * of the value.     * </div>     * <!-- end release-specific documentation -->     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return the column value; if the value is SQL <code>NULL</code>, the     * value returned is <code>null</code>     * @exception SQLException if a database access error occurs     */    public byte[] getBytes(int columnIndex) throws SQLException {        Object x = getObject(columnIndex);        if (x == null) {            return null;        }        if (x instanceof byte[]) {            return (byte[]) x;        }        if (x instanceof java.lang.String) {            return ((String) x).getBytes();        }        x = getColumnInType(columnIndex, Types.BINARY);        return (byte[]) x;    }    /**     * <!-- start generic documentation -->     * Retrieves the value of the designated column in the current row     * of this <code>ResultSet</code> object as a     * <code>java.sql.Date</code> object in the Java programming language.<p>     * <!-- end generic documentation -->     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return the column value; if the value is SQL <code>NULL</code>, the     * value returned is <code>null</code>     * @exception SQLException if a database access error occurs     */    public Date getDate(int columnIndex) throws SQLException {        return (Date) getColumnInType(columnIndex, Types.DATE);    }    /**     * <!-- start generic documentation -->     * Retrieves the value of the designated column in the current row     * of this <code>ResultSet</code> object as a <code>java.sql.Time</code>     * object in the Java programming language. <p>     * <!-- end generic documentation -->     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return the column value; if the value is SQL <code>NULL</code>, the     * value returned is <code>null</code>     * @exception SQLException if a database access error occurs     */    public Time getTime(int columnIndex) throws SQLException {        return (Time) getColumnInType(columnIndex, Types.TIME);    }    /**     * <!-- start generic documentation -->     * Retrieves the value of the designated column in the current row     * of this <code>ResultSet</code> object as     * a <code>java.sql.Timestamp</code> object in the Java programming     * language. <p>     * <!-- end generic documentation -->     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return the column value; if the value is SQL <code>NULL</code>, the     * value returned is <code>null</code>     * @exception SQLException if a database access error occurs     */    public Timestamp getTimestamp(int columnIndex) throws SQLException {        return (Timestamp) getColumnInType(columnIndex, Types.TIMESTAMP);    }    /**     * <!-- start generic documentation -->     * Retrieves the value of the designated column in the current row     * of this <code>ResultSet</code> object 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 <char>LONGVARCHAR</char> 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 getter method implicitly closes the stream.  Also, a     * stream may return <code>0</code> when the method     * <code>InputStream.available</code>     * is called whether there is data available or not. <p>     * <!-- end generic documentation -->     *     * <!-- start release-specific documentation -->     * <div class="ReleaseSpecificDocumentation">     * <h3>HSQLDB-Specific Information:</h3> <p>     *     * The limitation noted above does not apply to HSQLDB.<p>     *     * In 1.6.1 and previous, getAsciiStream was identical to     * getUnicodeStream and both simply returned a byte stream     * constructed from the raw {@link #getBytes(int) getBytes}     * representation.     *     * Starting with 1.7.0, this has been updated to comply with the     * java.sql specification.     *     * When the column is of type CHAR and its variations, it requires no     * conversion since it is represented internally already as a     * Java String object. When the column is not of type CHAR and its     * variations, the returned stream is based on a conversion to the     * Java <code>String</code> representation of the value. In either case,     * the obtained stream is always equivalent to a stream of the low order     * bytes from the value's String representation. <p>     *     * HSQLDB SQL <code>CHAR</code> and its variations are all Unicode strings     * internally, so the recommended alternatives to this method are     * {@link #getString(int) getString},     * {@link #getUnicodeStream(int) getUnicodeStream} (<b>deprecated</b>)     * and new to 1.7.0: {@link #getCharacterStream(int) getCharacterStream}     * (now prefered over the deprecated getUnicodeStream alternative).     * </div>     * <!-- end release-specific documentation -->     *     * @param columnIndex the first column is 1, the second is 2, ...     * @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     * value returned is <code>null</code>     * @exception SQLException if a database access error occurs     */    public java.io.InputStream getAsciiStream(int columnIndex)    throws SQLException {        String s = getString(columnIndex);        if (s == null) {            return null;        }        return new AsciiStringInputStream(s);    }    /**     * <!-- start generic documentation -->     * Retrieves the value of the designated column in the current row     * of this <code>ResultSet</code> object as     * as a stream of two-byte Unicode characters. The first byte is     * the high byte; the second byte is the low byte.     *

⌨️ 快捷键说明

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