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

📄 simpletextresultset.java

📁 codebook!
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        int scale)        throws SQLException    {        return getBigDecimal(findColumn(columnName), scale);    }    //------------------------------------------------------------------------    // getBytes - JDBC API    // Get the value of a column in the current row as a Java byte array.    // The bytes represent the raw values returned by the driver.    //    //    columnName        is the SQL name of the column    //    // Returns the column value; if the value is SQL NULL the result is null    //------------------------------------------------------------------------    public byte[] getBytes(        String columnName)        throws SQLException    {        return getBytes(findColumn(columnName));    }    //------------------------------------------------------------------------    // getDate - JDBC API    // Get the value of a column in the current row as a java.sql.Date object.    //    //    columnName        is the SQL name of the column    //    // Returns the column value; if the value is SQL NULL the result is null    //------------------------------------------------------------------------    public java.sql.Date getDate(        String columnName)        throws SQLException    {        return getDate(findColumn(columnName));    }    //------------------------------------------------------------------------    // getTime - JDBC API    // Get the value of a column in the current row as a java.sql.Time object.    //    //    columnName        is the SQL name of the column    //    // Returns the column value; if the value is SQL NULL the result is null    //------------------------------------------------------------------------    public java.sql.Time getTime(        String columnName)        throws SQLException    {        return getTime(findColumn(columnName));    }    //------------------------------------------------------------------------    // getTimestamp - JDBC API    // Get the value of a column in the current row as a java.sql.Timestamp    // object.    //    //    columnName        is the SQL name of the column    // Returns the column value; if the value is SQL NULL the result is null    //------------------------------------------------------------------------    public java.sql.Timestamp getTimestamp(        String columnName)        throws SQLException    {        return getTimestamp(findColumn(columnName));    }    //------------------------------------------------------------------------    // getAsciiStream    // A column value can be retrieved as a stream of ASCII characters    // and then 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.    //    // Note:  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.    //    //    columnName        is the SQL name of the column    //    // Returns 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.    //------------------------------------------------------------------------    public java.io.InputStream getAsciiStream(        String columnName)        throws SQLException    {        return getAsciiStream(findColumn(columnName));    }    //------------------------------------------------------------------------    // getUnicodeStream - JDBC API    // A column value can be retrieved as a stream of Unicode characters    // and then 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.    //    // Note:  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.    //    //    columnName        is the SQL name of the column    //    // Returns 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.    //------------------------------------------------------------------------    public java.io.InputStream getUnicodeStream(        String columnName)        throws SQLException    {        return getUnicodeStream(findColumn(columnName));    }    //------------------------------------------------------------------------    // getBinaryStream - JDBC API    // A column value can be retrieved as a stream of uninterpreted bytes    // and then read in chunks from the stream.  This method is particularly    // suitable for retrieving large LONGVARBINARY values.    //    // Note:  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.    //    //    columnName        is the SQL name of the column    //    // Returns 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.    //------------------------------------------------------------------------    public java.io.InputStream getBinaryStream(        String columnName)        throws SQLException    {        return getBinaryStream(findColumn(columnName));    }    //=====================================================================    // Advanced features:    //=====================================================================    //------------------------------------------------------------------------    // getWarnings - JDBC API    // The first warning reported by calls on this ResultSet is    // returned. Subsequent ResultSet warnings will be chained to this    // SQLWarning.    //    // The warning chain is automatically cleared each time a new    // row is read.    //    // Note:  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.    //    // Returns the first SQLWarning or null    //------------------------------------------------------------------------    public SQLWarning getWarnings()        throws SQLException    {        return lastWarning;    }    //------------------------------------------------------------------------    // clearWarnings - JDBC API    // After this call getWarnings returns null until a new warning is    // reported for this ResultSet.    //------------------------------------------------------------------------    public void clearWarnings()        throws SQLException    {        setWarning(null);    }    //------------------------------------------------------------------------    // setWarning    // Sets the given SQLWarning in the warning chain.  If null, the    // chain is reset    //------------------------------------------------------------------------    protected void setWarning(        SQLWarning warning)    {        if (warning == null) {            lastWarning = null;        }        else {            SQLWarning chain = lastWarning;            // Find the end of the chain            while (chain.getNextWarning() != null) {                chain = chain.getNextWarning();            }            // We're at the end of the chain.  Add the new warning            chain.setNextWarning(warning);        }    }    //------------------------------------------------------------------------    // getCursorName - JDBC API    // Get the name of the SQL cursor used by this ResultSet.    //    // 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.    //    // 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.    //    // Note:  If positioned update is not supported a    // SQLException is thrown    //    // Returns the ResultSet's SQL cursor name    //------------------------------------------------------------------------    public String getCursorName()        throws SQLException    {        // The SimpleText driver does not support positioned updates        throw DriverNotCapable();    }    //------------------------------------------------------------------------    // getMetaData - JDBC API    // The number, types and properties of a ResultSet's columns    // are provided by the getMetaData method.    //    // Returns the description of a ResultSet's columns    //------------------------------------------------------------------------    public ResultSetMetaData getMetaData()        throws SQLException    {        SimpleTextResultSetMetaData md = new SimpleTextResultSetMetaData();        md.initialize(inMemoryColumns, ownerConnection.isReadOnly());        return md;    }    //------------------------------------------------------------------------    // getObject - JDBC API    // Get the value of a column as a Java object.    //    // This method will return the value of the given column as a Java    // object.  The type of the Java object will be default Java Object type    // corresponding to the column's SQL type, following the mapping    // specified in the JDBC spec.    //    // This method may also be used to read datatabase specific abstract    // data types.    //    //    columnIndex the first column is 1, the second is 2, ...    //    // Returns A java.lang.Object holding the column value.    //------------------------------------------------------------------------    public Object getObject(        int columnIndex)        throws SQLException    {        // Verify the column        verify(columnIndex);        // Get the data type of the column        int type = (getColumn(columnIndex)).type;        // The CommonValue for the column        CommonValue value;        if (inMemoryRows != null) {            value = getColumn(rowNum, columnIndex);        }        else {            value = getValue(columnIndex);        }        // Check for a null value        if (value == null) {            lastNull = true;            return null;        }        if (value.isNull()) {            lastNull = true;            return null;        }        Object o = null;        // Return the appropriate object for the given type        switch(type) {        case Types.VARCHAR:            o = value.getString();            break;        case Types.INTEGER:            o = new Integer(value.getInt());            break;        case Types.VARBINARY:            o = value.getBytes();            break;        default:            throw DataTypeNotSupported();        }        return o;    }    //------------------------------------------------------------------------    // getObject - JDBC API    // Get the value of a parameter as a Java object.    //    // This method will return the value of the given column as a Java    // object.  The type of the Java object will be default Java Object type    // corresponding to the column's SQL type, following the mapping    // specified in the JDBC spec.    //    // This method may also be used to read datatabase specific abstract    // data types.    //    //    columnName        is the SQL name of the column    //    // Returns A java.lang.Object holding the column value.    //------------------------------------------------------------------------    public Object getObject(        String columnName)        throws SQLException    {        return getObject(findColumn(columnName));    }    //------------------------------------------------------------------------    // findColumn - JDBC API    // Map a Resultset column name to a ResultSet column index.    //    //    columnName    the name of the column    //    // Returns the column index    //    // Note:  The code implemented here comes from appendix C of the    // JDBC API.    //------------------------------------------------------------------------    public int findColumn(        String columnName)        throws SQLException    {        // Make a mapping cache if we don't already have one.        if (md == null) {            md = getMetaData();            s2c = new Hashtable();        }        // Look for the mapping in our cache        Integer x = (Integer) s2c.get(columnName);        if (x != null) {            return (x.intValue());        }        // OK, we'll have to use metadata        for (int i = 1; i <= md.getColumnCount(); i++) {            if (md.getColumnName(i).equalsIgnoreCase(columnName)) {                // Success!  Add an entry to the cache                s2c.put(columnName, new Integer(i));                return (i);            }        }        throw new SQLException("Column name not found: " + columnName,                            "S0022");    }    //------------------------------------------------------------------------    // verify    // Verifies the column number given is valid, and resets the warnings

⌨️ 快捷键说明

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