jdbcresultset.java
来自「一个可以在applet窗体上持行sql语句并显示返回结果的程序」· Java 代码 · 共 1,814 行 · 第 1/5 页
JAVA
1,814 行
* JDBC 2.0
*
* Gets the value of a column in the current row as a java.math.BigDecimal
* object 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 NULL,
* the result is null
* @exception SQLException if a database access error occurs
*/
//#ifdef JAVA2
public BigDecimal getBigDecimal(int column) throws SQLException {
return getBigDecimal(column,0);
}
//#endif JAVA2
/**
* JDBC 2.0
*
* Gets the value of a column in the current row as a java.math.BigDecimal
* object with full precision.
* @param columnName the column name
* @return the column value (full precision); if the value is SQL NULL,
* the result is null
* @exception SQLException if a database access error occurs
*
*/
//#ifdef JAVA2
public BigDecimal getBigDecimal(String columnName) throws SQLException {
return getBigDecimal(findColumn(columnName));
}
//#endif JAVA2
/**
* JDBC 2.0
*
* <p>Indicates whether the cursor is before the first row in the result
* set.
*
* @return true if the cursor is before the first row, false otherwise. Returns
* false when the result set contains no rows.
*/
//#ifdef JAVA2
public boolean isBeforeFirst() {
if(Trace.TRACE) Trace.trace();
if(bInit==false) {
return true;
}
return false;
}
//#endif JAVA2
/**
* JDBC 2.0
*
* <p>Indicates whether the cursor is after the last row in the result
* set.
*
* @return true if the cursor is after the last row, false otherwise.
* Returns false when the result set contains no rows.
*/
//#ifdef JAVA2
public boolean isAfterLast() {
if(Trace.TRACE) Trace.trace();
if(bInit==false) {
return false;
}
if(nCurrent==null) {
return true;
}
return false;
}
//#endif JAVA2
/**
* JDBC 2.0
*
* <p>Indicates whether the cursor is on the first row of the result set.
*
* @return true if the cursor is on the first row, false otherwise.
*/
//#ifdef JAVA2
public boolean isFirst() {
if(Trace.TRACE) Trace.trace();
return iCurrentRow==1;
}
//#endif JAVA2
/**
* JDBC 2.0
*
* <p>Indicates whether the cursor is on the last row of the result set.
* Note: Calling the method <code>isLast</code> may be expensive
* because the JDBC driver
* might need to fetch ahead one row in order to determine
* whether the current row is the last row in the result set.
*
* @return true if the cursor is on the last row, false otherwise.
* @exception SQLException if a database access error occurs
*/
//#ifdef JAVA2
public boolean isLast() throws SQLException {
if(Trace.TRACE) Trace.trace();
throw Trace.error(Trace.FUNCTION_NOT_SUPPORTED);
}
//#endif JAVA2
/**
* JDBC 2.0
*
* <p>Moves the cursor to the front of the result set, just before the
* first row. Has no effect if the result set contains no rows.
*
* @exception SQLException if a database access error occurs or the
* result set type is TYPE_FORWARD_ONLY
*/
//#ifdef JAVA2
public void beforeFirst() throws SQLException {
if(Trace.TRACE) Trace.trace();
throw Trace.error(Trace.FUNCTION_NOT_SUPPORTED);
}
//#endif JAVA2
/**
* JDBC 2.0
*
* <p>Moves the cursor to the end of the result set, just after the last
* row. Has no effect if the result set contains no rows.
*
* @exception SQLException if a database access error occurs or the
* result set type is TYPE_FORWARD_ONLY
*/
//#ifdef JAVA2
public void afterLast() throws SQLException {
if(Trace.TRACE) Trace.trace();
throw Trace.error(Trace.FUNCTION_NOT_SUPPORTED);
}
//#endif JAVA2
/**
* JDBC 2.0
*
* <p>Moves the cursor to the first row in the result set.
*
* @return true if the cursor is on a valid row; false if
* there are no rows in the result set
* @exception SQLException if a database access error occurs or the
* result set type is TYPE_FORWARD_ONLY
*/
//#ifdef JAVA2
public boolean first() throws SQLException {
if(Trace.TRACE) Trace.trace();
throw Trace.error(Trace.FUNCTION_NOT_SUPPORTED);
}
//#endif JAVA2
/**
* JDBC 2.0
*
* <p>Moves the cursor to the last row in the result set.
*
* @return true if the cursor is on a valid row;
* false if there are no rows in the result set
* @exception SQLException if a database access error occurs or the
* result set type is TYPE_FORWARD_ONLY.
*/
//#ifdef JAVA2
public boolean last() throws SQLException {
if(Trace.TRACE) Trace.trace();
throw Trace.error(Trace.FUNCTION_NOT_SUPPORTED);
}
//#endif JAVA2
/**
* JDBC 2.0
*
* <p>Retrieves the current row number. The first row is number 1, the
* second number 2, and so on.
*
* @return the current row number; 0 if there is no current row
*/
//#ifdef JAVA2
public int getRow() {
if(Trace.TRACE) Trace.trace();
return iCurrentRow;
}
//#endif JAVA2
/**
* JDBC 2.0
*
* <p>Moves the cursor to the given row number in the result set.
*
* <p>If the row number is positive, the cursor moves to
* the given row number with respect to the
* beginning of the result set. The first row is row 1, the second
* is row 2, and so on.
*
* <p>If the given row number is negative, the cursor moves to
* an absolute row position with respect to
* the end of the result set. For example, calling
* <code>absolute(-1)</code> positions the
* cursor on the last row, <code>absolute(-2)</code> indicates the
* next-to-last row, and so on.
*
* <p>An attempt to position the cursor beyond the first/last row in
* the result set leaves the cursor before/after the first/last
* row, respectively.
*
* <p>Note: Calling <code>absolute(1)</code> is the same
* as calling <code>first()</code>.
* Calling <code>absolute(-1)</code> is the same as calling
* <code>last()</code>.
*
* @return true if the cursor is on the result set; false otherwise
* @exception SQLException if a database access error occurs or
* row is 0, or result set type is TYPE_FORWARD_ONLY.
*/
//#ifdef JAVA2
public boolean absolute(int row) throws SQLException {
if(Trace.TRACE) Trace.trace();
throw Trace.error(Trace.FUNCTION_NOT_SUPPORTED);
}
//#endif JAVA2
/**
* JDBC 2.0
*
* <p>Moves the cursor a relative number of rows, either positive or negative.
* Attempting to move beyond the first/last row in the
* result set positions the cursor before/after the
* the first/last row. Calling <code>relative(0)</code> is valid, but does
* not change the cursor position.
*
* <p>Note: Calling <code>relative(1)</code>
* is different from calling <code>next()</code>
* because is makes sense to call <code>next()</code> when there is no
* current row,
* for example, when the cursor is positioned before the first row
* or after the last row of the result set.
*
* @return true if the cursor is on a row; false otherwise
* @exception SQLException if a database access error occurs, there
* is no current row, or the result set type is TYPE_FORWARD_ONLY
*/
//#ifdef JAVA2
public boolean relative(int rows) throws SQLException {
if(Trace.TRACE) Trace.trace();
if(rows<0) {
throw Trace.error(Trace.FUNCTION_NOT_SUPPORTED);
}
while(rows-->0) {
next();
}
return nCurrent!=null;
}
//#endif JAVA2
/**
* JDBC 2.0
*
* <p>Moves the cursor to the previous row in the result set.
*
* <p>Note: <code>previous()</code> is not the same as
* <code>relative(-1)</code> because it
* makes sense to call</code>previous()</code> when there is no current row.
*
* @return true if the cursor is on a valid row; false if it is off the
* result set
* @exception SQLException if a database access error occurs or the
* result set type is TYPE_FORWARD_ONLY
*/
//#ifdef JAVA2
public boolean previous() throws SQLException {
if(Trace.TRACE) Trace.trace();
throw Trace.error(Trace.FUNCTION_NOT_SUPPORTED);
}
//#endif JAVA2
/**
* JDBC 2.0
*
* Gives a hint as to the direction in which the rows in this result set
* will be processed. The initial value is determined by the statement
* that produced the result set. The fetch direction may be changed
* at any time.
*
* @exception SQLException if a database access error occurs or
* the result set type is TYPE_FORWARD_ONLY and the fetch direction is not
* FETCH_FORWARD.
*/
//#ifdef JAVA2
public void setFetchDirection(int direction) throws SQLException {
if(Trace.TRACE) Trace.trace(direction);
if(direction!=ResultSet.FETCH_FORWARD) {
throw Trace.error(Trace.FUNCTION_NOT_SUPPORTED);
}
}
//#endif JAVA2
/**
* JDBC 2.0
*
* Returns the fetch direction for this result set.
*
* @return the current fetch direction for this result set
*/
//#ifdef JAVA2
public int getFetchDirection() {
return ResultSet.FETCH_FORWARD;
}
//#endif JAVA2
/**
* JDBC 2.0
*
* Gives the JDBC driver a hint as to the number of rows that should
* be fetched from the database when more rows are needed for this result
* set. If the fetch size specified is zero, the JDBC driver
* ignores the value and is free to make its own best guess as to what
* the fetch size should be. The default value is set by the statement
* that created the result set. The fetch size may be changed at any
* time.
*
* @param rows the number of rows to fetch
* @exception SQLException if a database access error occurs or the
* condition 0 <= rows <= this.getMaxRows() is not satisfied.
*/
//#ifdef JAVA2
public void setFetchSize(int rows) throws SQLException {
if(Trace.TRACE) Trace.trace(rows);
}
//#endif JAVA2
/**
* JDBC 2.0
*
* Returns the fetch size for this result set.
*
* @return the current fetch size for this result set
*/
//#ifdef JAVA2
public int getFetchSize() {
if(Trace.TRACE) Trace.trace();
return 1;
}
//#endif JAVA2
/**
* JDBC 2.0
*
* Returns the type of this result set. The type is determined by
* the statement that created the result set.
*
* @return TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE, or
* TYPE_SCROLL_SENSITIVE
*/
//#ifdef JAVA2
public int getType() {
if(Trace.TRACE) Trace.trace();
return TYPE_FORWARD_ONLY;
}
//#endif JAVA2
/**
* JDBC 2.0
*
* Returns the concurrency mode of this result set. The concurrency
* used is determined by the statement that created the result set.
*
* @return the concurrency type, CONCUR_READ_ONLY or CONCUR_UPDATABLE
*/
//#ifdef JAVA2
public int getConcurrency() {
if(Trace.TRACE) Trace.trace();
return CONCUR_READ_ONLY;
}
//#endif JAVA2
/**
* JDBC 2.0
*
* Indicates whether the current row has been updated. The value returned
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?