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

📄 resultset.html

📁 API資料大全
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Thu Apr 27 23:36:25 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Interface  ResultSet</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">  <TR ALIGN="center" VALIGN="top">  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/ResultSet.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup>&nbsp;2&nbsp;Platform<br>Std.&nbsp;Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;<A HREF="../../java/sql/Ref.html"><B>PREV CLASS</B></A>&nbsp;&nbsp;<A HREF="../../java/sql/ResultSetMetaData.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">  <A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A>  &nbsp;&nbsp;<A HREF="ResultSet.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">  SUMMARY: &nbsp;INNER&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: &nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">java.sql</FONT><BR>Interface  ResultSet</H2><HR><DL><DT>public interface <B>ResultSet</B></DL><P>A table of data representing a database result set, which is usually generated by executing a statement that queries the database.   <P>A <code>ResultSet</code> object  maintains a cursor pointing to its current row of data.  Initially the cursor is positioned  before the first row. The <code>next</code> method moves the  cursor to the next row, and because it returns <code>false</code> when there are no more rows in the <code>ResultSet</code> object, it can be used in a <code>while</code> loop to iterate through  the result set. <P> A default <code>ResultSet</code> object is not updatable and has a cursor that moves forward only.  Thus, it is possible to iterate through it only once and only from the first row to the last row.  New methods in the JDBC 2.0 API make it possible to produce <code>ResultSet</code> objects that are scrollable and/or updatable.  The following code fragment, in which <code>con</code> is a valid <code>Connection</code> object, illustrates how to make  a result set that is scrollable and insensitive to updates by others, and  that is updatable. See <code>ResultSet</code> fields for other options. <PRE>       Statement stmt = con.createStatement(                                      ResultSet.TYPE_SCROLL_INSENSITIVE,                                      ResultSet.CONCUR_UPDATABLE);       ResultSet rs = stmt.executeQuery("SELECT a, b FROM TABLE2");       // rs will be scrollable, will not show changes made by others,       // and will be updatable </PRE> The <code>ResultSet</code> interface provides  <code>getXXX</code> methods for retrieving column values from the current row. Values can be retrieved using either the index number of the column or the name of the column.  In general, using the  column index will be more efficient.  Columns are numbered from 1. For maximum portability, result set columns within each row should be read in left-to-right order, and each column should be read only once. <P>For the <code>getXXX</code> methods, a JDBC driver attempts to convert the underlying data to the Java type specified in the <code>XXX</code> part of the <code>getXXX</code> method and returns a suitable Java value.  The JDBC specification  has a table showing the allowable mappings from SQL types to Java types with the <code>ResultSet.getXXX</code> methods. <P> <P>Column names used as input to <code>getXXX</code> methods are case insensitive.  When a <code>getXXX</code> method is called  with a column name and several columns have the same name,  the value of the first matching column will be returned.  The column name option is designed to be used when column names are used in the SQL query that generated the result set. For columns that are NOT explicitly named in the query, it is best to use column numbers. If column names are used, there is no way for the programmer to guarantee that they actually refer to the intended columns. <P> A set of <code>updateXXX</code> methods were added to this interface in the JDBC 2.0 API (Java<sup><font size=-2>TM</font></sup> 2 SDK, Standard Edition, version 1.2). The comments regarding parameters to the <code>getXXX</code> methods also apply to parameters to the <code>updateXXX</code> methods.<P> The <code>updateXXX</code> methods may be used in two ways: <ol> <LI>to update a column value in the current row.  In a scrollable     <code>ResultSet</code> object, the cursor can be moved backwards     and forwards, to an absolute position, or to a position     relative to the current row.     The following code fragment updates the <code>NAME</code> column     in the fifth row of the <code>ResultSet</code> object     <code>rs</code> and then uses the method <code>updateRow</code>     to update the data source table from which <code>rs</code> was derived. <PRE>       rs.absolute(5); // moves the cursor to the fifth row of rs       rs.updateString("NAME", "AINSWORTH"); // updates the           // <code>NAME</code> column of row 5 to be <code>AINSWORTH</code>       rs.updateRow(); // updates the row in the data source </PRE> <LI>to insert column values into the insert row.  An updatable     <code>ResultSet</code> object has a special row associated with     it that serves as a staging area for building a row to be inserted.     The following code fragment moves the cursor to the insert row, builds     a three-column row, and inserts it into <code>rs</code> and into     the data source table using the method <code>insertRow</code>. <PRE>       rs.moveToInsertRow(); // moves cursor to the insert row       rs.updateString(1, "AINSWORTH"); // updates the           // first column of the insert row to be <code>AINSWORTH</code>       rs.updateInt(2,35); // updates the second column to be <code>35</code>       rs.updateBoolean(3, true); // updates the third row to <code>true</code>       rs.insertRow();       rs.moveToCurrentRow(); </PRE> </ol> <P>A <code>ResultSet</code> object is automatically closed when the <code>Statement</code> object that generated it is closed, re-executed, or used to retrieve the next result from a sequence of multiple results.  <P>The number, types and properties of a <code>ResultSet</code> object's columns are provided by the <code>ResulSetMetaData</code> object returned by the <code>ResultSet.getMetaData</code> method.<P><DL><DT><B>See Also: </B><DD><A HREF="../../java/sql/Statement.html#executeQuery(java.lang.String)"><CODE>Statement.executeQuery(java.lang.String)</CODE></A>, <A HREF="../../java/sql/Statement.html#getResultSet()"><CODE>Statement.getResultSet()</CODE></A>, <A HREF="../../java/sql/ResultSetMetaData.html"><CODE>ResultSetMetaData</CODE></A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><A NAME="field_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Field Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/ResultSet.html#CONCUR_READ_ONLY">CONCUR_READ_ONLY</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The constant indicating the concurrency mode for a <code>ResultSet</code> object that may NOT be updated.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/ResultSet.html#CONCUR_UPDATABLE">CONCUR_UPDATABLE</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The constant indicating the concurrency mode for a <code>ResultSet</code> object that may be updated.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/ResultSet.html#FETCH_FORWARD">FETCH_FORWARD</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The constant indicating that the rows in a result set will be  processed in a forward direction; first-to-last.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/ResultSet.html#FETCH_REVERSE">FETCH_REVERSE</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The constant indicating that the rows in a result set will be  processed in a reverse direction; last-to-first.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/ResultSet.html#FETCH_UNKNOWN">FETCH_UNKNOWN</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The constant indicating that the order in which rows in a  result set will be processed is unknown.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/ResultSet.html#TYPE_FORWARD_ONLY">TYPE_FORWARD_ONLY</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The constant indicating the type for a <code>ResultSet</code> object whose cursor may move only forward.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/ResultSet.html#TYPE_SCROLL_INSENSITIVE">TYPE_SCROLL_INSENSITIVE</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The constant indicating the type for a <code>ResultSet</code> object that is scrollable but generally not sensitive to changes made by others.</TD></TR>

⌨️ 快捷键说明

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