Cause:
Today, I want to develop a program to flip the page of the article list. I need to obtain the total number of data rows in the dataset.
The method used is as follows:
--------------------------------------------------
Int rowcount = 0;
Rs. Last ();
Rowcount = Rs. getrow ();// Move to the end to retrieve the number of the current row and obtain the total number of rows.
Out. Print ("Total number of rows:" + rowcount + "<br/> ");
// Out. Print ("islast:" + Rs. islast () + "<br/> ");
// Out. Print ("isafterlast:" + Rs. isafterlast () + "<br/> ");
Rs. beforefirst (); // easy to output data later
---------------------------------------------------
This method is not supported when Rs. Last () is executed!
[Microsoft] [sqlserver 2000 driver for JDBC] unsupported method: resultset. Last
Data analysis:
==================================Cursor read-only forward======================================
Java. SQL
Interface: Connection
Method:Createstatement
Statement createstatement ()
Throws sqlexception
Create a statement object to send SQL statements to the database.
SQL statements without parameters are usually executed using statement objects.
If you execute the same SQL statement multiple times, the preparedstatement object may be more effective.
The result set created using the returned statement object is of the type_forward_only type by default,
And has the concur_read_only concurrency level. [--- Note that the cursor is read-only forward by default]
Return Value:
A new default statement object
Throw:
Sqlexception-if a database access error occurs
======================================Custom cursors==============================================
Java. SQL
Interface: Connection
Method: createstatement
Statement createstatement (INT resultsettype,
Int resultsetconcurrency)
Throws sqlexceptionCreate a statement object that will generate
The resultset object of the given type and concurrency. This method is the same as the createstatement method, but it allows rewriting.
The default result set type and concurrency.
Parameters:
Resultsettype-result set type, which is
--- Resultset. type_forward_only, // forward cursor
--- Resultset. type_scroll_insensitive or // This constant indicates the RS type that can be rolled but is generally not affected by other changes
--- One of resultset. type_scroll_sensitive // Constant indicates the RS type that can be rolled and is usually affected by other changes.
Resultsetconcurrency-concurrency type; it is
--- Resultset. concur_read_only or // read-only
--- Resultset. concur_updatable // you can modify it.
Return Value:
A new statement object that generates a resultset object with a given type and concurrency
Throw:
Sqlexception-if a database access error occurs, or the given parameter is not a resultset constant indicating the type and concurrency
Start with the following versions:
1.2
Solution:
Specify the cursor parameter when creating a statement object
Conn = drivermanager. getconnection (getconnectionurl (), dbusername, dbpassword );
Stmt = conn. createstatement (resultset. type_scroll_sensitive, resultset. concur_updatable );