📄 jdbcresultset.java
字号:
rResult = null; } /** * <!-- start generic documentation --> * Reports whether * the last column read had a value of SQL <code>NULL</code>. * Note that you must first call one of the getter methods * on a column to try to read its value and then call * the method <code>wasNull</code> to see if the value read was * SQL <code>NULL</code>. <p> * <!-- end generic documentation --> * * <!-- start release-specific documentation --> * <span class="ReleaseSpecificDocumentation"> * </span> * <!-- end release-specific documentation --> * * @return <code>true</code> if the last column value read was SQL * <code>NULL</code> and <code>false</code> otherwise * @exception SQLException if a database access error occurs */ public boolean wasNull() throws SQLException { return bWasNull; } //====================================================================== // Methods for accessing results by column index //====================================================================== /** * <!-- start generic documentation --> * Retrieves the value of the designated column in the current row * of this <code>ResultSet</code> object as * a <code>String</code> in the Java programming language. <p> * <!-- end generic documentation --> * * <!-- start release-specific documentation --> * <span class="ReleaseSpecificDocumentation"> * </span> * <!-- 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 String getString(int columnIndex) throws SQLException { checkAvailable(); Object o; try { o = nCurrent.data[--columnIndex]; } catch (ArrayIndexOutOfBoundsException e) { throw Trace.error(Trace.COLUMN_NOT_FOUND, ++columnIndex); } // use checknull because getColumnInType is not used checkNull(o); return o == null ? null : o.toString(); } /** * <!-- start generic documentation --> * Retrieves the value of the designated column in the current row * of this <code>ResultSet</code> object as * a <code>boolean</code> in the Java programming language. <p> * <!-- end generic documentation --> * * <!-- start release-specific documentation --> * <span class="ReleaseSpecificDocumentation"> * </span> * <!-- 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>false</code> * @exception SQLException if a database access error occurs */ public boolean getBoolean(int columnIndex) throws SQLException { Object o = getColumnInType(columnIndex, Types.BIT); return o == null ? false : ((Boolean) o).booleanValue(); } /** * <!-- 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> in the Java programming language. <p> * <!-- end generic documentation --> * * <!-- start release-specific documentation --> * <span class="ReleaseSpecificDocumentation"> * </span> * <!-- 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>0</code> * @exception SQLException if a database access error occurs */ public byte getByte(int columnIndex) throws SQLException { Object o = getColumnInType(columnIndex, Types.SMALLINT); return o == null ? 0 : ((Number) o).byteValue(); } /** * <!-- 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 --> * * <!-- start release-specific documentation --> * <span class="ReleaseSpecificDocumentation"> * </span> * <!-- 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>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 --> * * <!-- start release-specific documentation --> * <span class="ReleaseSpecificDocumentation"> * </span> * <!-- 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>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 --> * * <!-- start release-specific documentation --> * <span class="ReleaseSpecificDocumentation"> * </span> * <!-- 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>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 --> * * <!-- start release-specific documentation --> * <span class="ReleaseSpecificDocumentation"> * </span> * <!-- 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>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 --> * * <!-- start release-specific documentation --> * <span class="ReleaseSpecificDocumentation"> * </span> * <!-- 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>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 --> * <span class="ReleaseSpecificDocumentation"> * <b>HSQLDB-Specific Information:</b> <p> * * Beginning with 1.7.0, HSQLDB converts the result and sets the scale * with BigDecimal.ROUND_HALF_DOWN<p> * * </span> * <!-- 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 */ 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 Trace.error(Trace.INVALID_JDBC_ARGUMENT); } if (bd != null) { bd.setScale(scale, BigDecimal.ROUND_HALF_DOWN); } return bd; } /** * <!-- 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 --> * <span class="ReleaseSpecificDocumentation"> * <b>HSQLDB-Specific Information:</b> <p> * * Up to and including 1.7.1, 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. <p> * * </span> * <!-- 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; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -