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

📄 resultset.java

📁 在资料浩瀚的互联网中
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     */    public InputStream getAsciiStream(String columnName)        throws SQLException {        return getAsciiStream(findColumn(columnName));    }    //---------------------------------------------------------------------    // Traversal/Positioning    //---------------------------------------------------------------------    /**     * JDBC 2.0     *     * <p>     * Determine if the cursor is before the first row in the result set.     * </p>     *     * @return true if before the first row, false otherwise. Returns false     *         when the result set contains no rows.     *     * @exception SQLException if a database-access error occurs.     */    public boolean isBeforeFirst() throws SQLException {    	checkClosed();    	        return this.rowData.isBeforeFirst();    }    /**     * Get the value of a column in the current row as a java.math.BigDecimal     * object     *     * @param columnIndex the first column is 1, the second is 2...     * @param scale the number of digits to the right of the decimal     *     * @return the column value; if the value is SQL NULL, null     *     * @exception SQLException if a database access error occurs     *     * @deprecated     */    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(0);                    try {                        return val.setScale(scale);                    } catch (ArithmeticException ex) {                    	try {                    		return val.setScale(scale, BigDecimal.ROUND_HALF_UP);                    	} catch (ArithmeticException arEx) {                    		throw new SQLException(Messages.getString(                                "ResultSet.Bad_format_for_BigDecimal____124") //$NON-NLS-1$                                +stringVal +                                Messages.getString("ResultSet.___in_column__125") +                                columnIndex + "(" //$NON-NLS-1$                                + this.fields[columnIndex - 1] + ").",                                SQLError.SQL_STATE_ILLEGAL_ARGUMENT);                    	}                    }                }                try {                    val = new BigDecimal(stringVal);                } catch (NumberFormatException ex) {                    throw new SQLException(Messages.getString(                            "ResultSet.Bad_format_for_BigDecimal",                            new Object[] { new Integer(columnIndex), stringVal }),                        SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$                }                try {                    return val.setScale(scale);                } catch (ArithmeticException ex) {                	try {                		return val.setScale(scale, BigDecimal.ROUND_HALF_UP);                	} catch (ArithmeticException arithEx) {                		throw new SQLException(Messages.getString(                            "ResultSet.Bad_format_for_BigDecimal",                            new Object[] { new Integer(columnIndex), stringVal }),                        SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$                	}                }            }            return null;        }        return getNativeBigDecimal(columnIndex, scale);    }    /**     * DOCUMENT ME!     *     * @param columnName DOCUMENT ME!     * @param scale DOCUMENT ME!     *     * @return DOCUMENT ME!     *     * @throws SQLException DOCUMENT ME!     *     * @deprecated     */    public BigDecimal getBigDecimal(String columnName, int scale)        throws SQLException {        return getBigDecimal(findColumn(columnName), scale);    }    /**     * JDBC 2.0 Get the value of a column in the current row as a     * java.math.BigDecimal object.     *     * @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.     */    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(0);                    return val;                }                try {                    val = new BigDecimal(stringVal);                    return val;                } catch (NumberFormatException ex) {                    throw new SQLException(Messages.getString(                            "ResultSet.Bad_format_for_BigDecimal",                            new Object[] { new Integer(columnIndex), stringVal }),                        SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$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.     *     * @param columnName the name of the column to retrieve the value from     *     * @return the BigDecimal value in the column     *     * @throws SQLException if an error occurs     */    public BigDecimal getBigDecimal(String columnName)        throws SQLException {        return getBigDecimal(findColumn(columnName));    }    /**     * A column value can also be retrieved as a binary strea.  This method is     * suitable for retrieving LONGVARBINARY values.     *     * @param columnIndex the first column is 1, the second is 2...     *     * @return a Java InputStream that delivers the database column value as a     *         stream of bytes.  If the value is SQL NULL, then the result is     *         null     *     * @exception SQLException if a database access error occurs     *     * @see getAsciiStream     * @see getUnicodeStream     */    public InputStream getBinaryStream(int columnIndex)        throws SQLException {        checkRowPos();        if (!this.isBinaryEncoded) {            byte[] b = getBytes(columnIndex);            if (b != null) {                return new ByteArrayInputStream(b);            }            return null;        }        return getNativeBinaryStream(columnIndex);    }    /**     * DOCUMENT ME!     *     * @param columnName DOCUMENT ME!     *     * @return DOCUMENT ME!     *     * @throws SQLException DOCUMENT ME!     */    public InputStream getBinaryStream(String columnName)        throws SQLException {        return getBinaryStream(findColumn(columnName));    }    /**     * JDBC 2.0 Get a BLOB column.     *     * @param columnIndex the first column is 1, the second is 2, ...     *     * @return an object representing a BLOB     *     * @throws SQLException if an error occurs.     */    public java.sql.Blob getBlob(int columnIndex) throws SQLException {        if (!this.isBinaryEncoded) {            checkRowPos();            if ((columnIndex < 1) || (columnIndex > this.fields.length)) {                throw new SQLException(Messages.getString(                        "ResultSet.Column_Index_out_of_range",                        new Object[] {                            new Integer(columnIndex),                            new Integer(this.fields.length)                        }), SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$            }            try {                if (this.thisRow[columnIndex - 1] == null) {                	this.wasNullFlag = true;                } else {                	this.wasNullFlag = false;                }            } catch (NullPointerException ex) {            	this.wasNullFlag = true;            }            if (this.wasNullFlag) {                return null;            }            if (!this.connection.getEmulateLocators()) {                return new Blob((byte[]) this.thisRow[columnIndex - 1]);            }            return new BlobFromLocator(this, columnIndex);        }        return getNativeBlob(columnIndex);    }    /**     * JDBC 2.0 Get a BLOB column.     *     * @param colName the column name     *     * @return an object representing a BLOB     *     * @throws SQLException if an error occurs.     */    public java.sql.Blob getBlob(String colName) throws SQLException {        return getBlob(findColumn(colName));    }    /**     * Get the value of a column in the current row as a Java boolean     *     * @param columnIndex the first column is 1, the second is 2...     *     * @return the column value, false for SQL NULL     *     * @exception SQLException if a database access error occurs     */    public boolean getBoolean(int columnIndex) throws SQLException {        if (!this.isBinaryEncoded) {        	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) {        		if (this.thisRow[columnIndexMinusOne] == null) {        			this.wasNullFlag = true;        			        			return false;        		}        		        		this.wasNullFlag = false;        		        		if (((byte[])this.thisRow[columnIndexMinusOne]).length == 0) {        			return false;        		}        		        		return (((byte[])this.thisRow[columnIndexMinusOne])[0] > (byte)0);        		        	}                    	String stringVal = getString(columnIndex);            if ((stringVal != null) && (stringVal.length() > 0)) {                int c = Character.toLowerCase(stringVal.charAt(0));                return ((c == 't') || (c == 'y') || (c == '1') ||                stringVal.equals("-1"));            }            return false;        }        return getNativeBoolean(columnIndex);    }    /**     * DOCUMENT ME!     *     * @param columnName DOCUMENT ME!     *     * @return DOCUMENT ME!     *     * @throws SQLException DOCUMENT ME!     */    public boolean getBoolean(String columnName) throws SQLException {        return getBoolean(findColumn(columnName));    }    /**     * Get the value of a column in the current row as a Java byte.     *     * @param columnIndex the first column is 1, the second is 2,...     *     * @return the column value; 0 if SQL NULL     *     * @exception SQLException if a database access error occurs     */    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);    }    /**     * DOCUMENT ME!     *     * @param columnName DOCUMENT ME!     *     * @return DOCUMENT ME!     *     * @throws SQLException DOCUMENT ME!     */    public byte getByte(String columnName) throws SQLException {        return getByte(findColumn(columnName));    }    /**     * Get the value of a column in the current row as a Java byte array.     *     * <p>     * <b>Be warned</b> If the blob is huge, then you may run out of memory.     * </p>     *     * @param columnIndex the first column is 1, the second is 2, ...     *     * @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(int columnIndex) throws SQLException {    	return getBytes(columnIndex, false);    }        protected byte[] getBytes(int columnIndex, boolean noConversion) throws SQLException {        if (!this.isBinaryEncoded) {            checkRowPos();            try {                if (this.thisRow[columnIndex - 1] == null) {                	this.wasNullFlag = true;                } else {                	this.wasNullFlag = false;                }            } catch (NullPointerException E) {            	this.wasNullFlag = true;

⌨️ 快捷键说明

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