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

📄 xmlresultset.java

📁 数据仓库工具
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
public InputStream getAsciiStream(String columnName) throws SQLException {
  String str = getString(columnName);
  is = new ByteArrayInputStream(str.getBytes());
  return (str == null) ? null : is;
}

/**
 * Retrieves the value of the designated column in the current row
 * of this <code>ResultSet</code> object as a stream of two-byte
 * Unicode characters. The first byte is the high byte; the second
 * byte is the low byte.
 *
 * The value can then be read in chunks from the
 * stream. This method is particularly
 * suitable for retrieving large <code>LONGVARCHAR</code> values.
 * The JDBC technology-enabled driver will
 * do any necessary conversion from the database format into Unicode.
 *
 * <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.
 *
 * @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 <code>NULL</code>, the value returned
 *         is <code>null</code>.
 * @exception SQLException if a database access error occurs
 * @deprecated use <code>getCharacterStream</code> instead
 */
public InputStream getUnicodeStream(String columnName) throws SQLException {
  // delegate to getAsciiStream(String)
  return getAsciiStream(columnName);
}

/**
 * Retrieves the value of the designated column in the current row
 * of this <code>ResultSet</code> object as a stream of uninterpreted
 * <code>byte</code>s.
 * The value can then be read in chunks from the
 * stream. This method is particularly
 * suitable for retrieving large <code>LONGVARBINARY</code>
 * values.
 *
 * <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>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 <code>NULL</code>, the result is <code>null</code>
 * @exception SQLException if a database access error occurs
 */
public InputStream getBinaryStream(String columnName) throws SQLException {
  // delegate to getAsciiStream(String)
  return getAsciiStream(columnName);
}

//=====================================================================
// Advanced features:
//=====================================================================

/**
 * Retrieves the first warning reported by calls on this
 * <code>ResultSet</code> object.
 * Subsequent warnings on this <code>ResultSet</code> object
 * will be chained to the <code>SQLWarning</code> object that
 * this method returns.
 *
 * <P>The warning chain is automatically cleared each time a new
 * row is read.  This method may not be called on a <code>ResultSet</code>
 * object that has been closed; doing so will cause an
 * <code>SQLException</code> to be thrown.
 * <P>
 * <B>Note:</B> This warning chain only covers warnings caused
 * by <code>ResultSet</code> methods.  Any warning caused by
 * <code>Statement</code> methods
 * (such as reading OUT parameters) will be chained on the
 * <code>Statement</code> object.
 *
 * @return the first <code>SQLWarning</code> object reported or
 *         <code>null</code> if there are none
 * @exception SQLException if a database access error occurs or this method
 *            is called on a closed result set
 */
public SQLWarning getWarnings() throws SQLException {
  throw new UnsupportedOperationException(
      "ResultSet.getWarnings() unsupported");
}

/**
 * Clears all warnings reported on this <code>ResultSet</code> object.
 * After this method is called, the method <code>getWarnings</code>
 * returns <code>null</code> until a new warning is
 * reported for this <code>ResultSet</code> object.
 *
 * @exception SQLException if a database access error occurs
 */
public void clearWarnings() throws SQLException {
  throw new UnsupportedOperationException(
      "ResultSet.clearWarnings() unsupported");
}

/**
 * Retrieves the name of the SQL cursor used by this <code>ResultSet</code>
 * object.
 *
 * <P>In SQL, a result table is retrieved through a cursor that is
 * named. The current row of a result set 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 <code>SELECT</code> statement
 * should be of the form <code>SELECT FOR UPDATE</code>. If
 * <code>FOR UPDATE</code> is omitted, the positioned updates may fail.
 *
 * <P>The JDBC API supports this SQL feature by providing the name of the
 * SQL cursor used by a <code>ResultSet</code> object.
 * The current row of a <code>ResultSet</code> object
 * is also the current row of this SQL cursor.
 *
 * <P><B>Note:</B> If positioned update is not supported, a
 * <code>SQLException</code> is thrown.
 *
 * @return the SQL name for this <code>ResultSet</code> object's cursor
 * @exception SQLException if a database access error occurs
 */
public String getCursorName() throws SQLException {
  throw new UnsupportedOperationException(
      "ResultSet.getCursorName() unsupported");
}

/**
 * Retrieves the  number, types and properties of
 * this <code>ResultSet</code> object's columns.
 *
 * @return the description of this <code>ResultSet</code> object's columns
 * @exception SQLException if a database access error occurs
 */
public ResultSetMetaData getMetaData() throws SQLException {
  if (resultSetMetaData == null) {
    resultSetMetaData = new XmlResultSetMetaData(tableName, columnNames);
  }
  return resultSetMetaData;

}

/**
 * <p>Gets the value of the designated column in the current row
 * of this <code>ResultSet</code> object as
 * an <code>Object</code> in the Java programming language.
 *
 * <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
 * specification. If the value is an SQL <code>NULL</code>,
 * the driver returns a Java <code>null</code>.
 *
 * <p>This method may also be used to read datatabase-specific
 * abstract data types.
 *
 * In the JDBC 2.0 API, the behavior of method
 * <code>getObject</code> is extended to materialize
 * data of SQL user-defined types.  When a column contains
 * a structured or distinct value, the behavior of this method is as
 * if it were a call to: <code>getObject(columnIndex,
 * this.getStatement().getConnection().getTypeMap())</code>.
 *
 * @param columnIndex the first column is 1, the second is 2, ...
 * @return a <code>java.lang.Object</code> holding the column value
 * @exception SQLException if a database access error occurs
 */
public Object getObject(int columnIndex) throws SQLException {
//        throw new UnsupportedOperationException(
//                "ResultSet.getObject(int) unsupported");
  return getString(columnIndex);
}
/**
 * <p>Gets the value of the designated column in the current row
 * of this <code>ResultSet</code> object as
 * an <code>Object</code> in the Java programming language.
 *
 * <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
 * specification. If the value is an SQL <code>NULL</code>,
 * the driver returns a Java <code>null</code>.
 * <P>
 * This method may also be used to read datatabase-specific
 * abstract data types.
 * <P>
 * In the JDBC 2.0 API, the behavior of the method
 * <code>getObject</code> is extended to materialize
 * data of SQL user-defined types.  When a column contains
 * a structured or distinct value, the behavior of this method is as
 * if it were a call to: <code>getObject(columnIndex,
 * this.getStatement().getConnection().getTypeMap())</code>.
 *
 * @param columnName the SQL name of the column
 * @return a <code>java.lang.Object</code> holding the column value
 * @exception SQLException if a database access error occurs
 */
public Object getObject(String columnName) throws SQLException {
//        throw new UnsupportedOperationException(
//                "ResultSet.getObject(String) unsupported");
  return getString(columnName);
}

/**
 * Maps the given <code>ResultSet</code> column name to its
 * <code>ResultSet</code> column index.
 *
 * @param columnName the name of the column
 * @return the column index of the given column name
 * @exception SQLException if the <code>ResultSet</code> object does
 * not contain <code>columnName</code> or a database access error occurs
 */
public int findColumn(String columnName) throws SQLException {
  throw new UnsupportedOperationException(
      "ResultSet.findColumn(String) unsupported");
}

//--------------------------JDBC 2.0-----------------------------------

//---------------------------------------------------------------------
// Getters and Setters
//---------------------------------------------------------------------

/**
 * Retrieves the value of the designated column in the current row
 * of this <code>ResultSet</code> object as a
 * <code>java.io.Reader</code> object.
 *
 * @param columnIndex the first column is 1, the second is 2, ...
 * @return a <code>java.io.Reader</code> object that contains the column
 * value; if the value is SQL <code>NULL</code>, the value returned is
 * <code>null</code> in the Java programming language.
 * @exception SQLException if a database access error occurs
 */
public Reader getCharacterStream(int columnIndex) throws SQLException {
  String str = getString(columnIndex);
  return (str == null) ? null : new StringReader(str);
}

/**
 * Retrieves the value of the designated column in the current row
 * of this <code>ResultSet</code> object as a
 * <code>java.io.Reader</code> object.
 *
 * @param columnName the name of the column
 * @return a <code>java.io.Reader</code> object that contains the column
 * value; if the value is SQL <code>NULL</code>, the value returned is
 * <code>null</code> in the Java programming language
 * @exception SQLException if a database access error occurs
 */
public Reader getCharacterStream(String columnName) throws SQLException {
  String str = getString(columnName);
  return (str == null) ? null : new StringReader(str);
}

/**
 * Retrieves the value of the designated column in the current row
 * of this <code>ResultSet</code> object as a
 * <code>java.math.BigDecimal</code> 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 <code>NULL</code>, the value returned is
 * <code>null</code> in the Java programming language.
 * @exception SQLException if a database access error occurs
 */
public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
  BigDecimal retval = null;
  String str = getString(columnIndex);
  if(str != null) {
    try {
      retval = new BigDecimal(str);
    }
    catch (NumberFormatException e) {
      throw new SQLException("Could not convert '" + str + "' to " +
                             "a java.math.BigDecimal object");
    }
  }
  return retval;
}

/**
 * Retrieves the value of the designated column in the current row
 * of this <code>ResultSet</code> object as a
 * <code>java.math.BigDecimal</code> with full precision.
 *
 * @param columnName the column name
 * @return the column value (full precision);
 * if the value is SQL <code>NULL</code>, the value returned is
 * <code>null</code> in the Java programming language.
 * @exception SQLException if a database access error occurs
 */
public BigDecimal getBigDecimal(String columnName) throws SQLException {
  BigDecimal retval = null;
  String str = getString(columnName);
  if(str != null) {
    try {
      retval = new BigDecimal(str);
    }
    catch (NumberFormatException e) {
      throw new SQLException("Could not convert '" + str + "' to " +
                             "a java.math.BigDecimal object");
    }
  }
  return retval;
}

//---------------------------------------------------------------------
// Traversal/Positioning
//---------------------------------------------------------------------

/**
 * Retrieves whether the cursor is before the first row in
 * this <code>ResultSet</code> object.
 *
 * @return <code>true</code> if the cursor is before the first row;
 * <code>false</code> if the cursor is at any other position or the
 * result set contains no rows
 * @exception SQLException if a database access error occurs

⌨️ 快捷键说明

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