rs.last();
int i=rs.getRow();
out.print(i);

解决方案 »

  1.   

    mysql中现在还有很多jdbc2.0中规定的特性(feature)没有支持。大家等待他的改进吧。但是就目前而言,如mm.mysql.jdbc-2.0pre5中是有对这个的支持的。    /**
         * JDBC 2.0
         *
         * <p>Moves to the last row in the result set.  
         *
         * @return true if on a valid row, false if no rows in the result set.
         * @exception SQLException if a database-access error occurs, or
         * result set type is TYPE_FORWARD_ONLY.
         */    public synchronized boolean last() throws SQLException
        {

    if (Rows.size() == 0) {
        return false;
    }
    else {
        if (_on_insert_row) {
    _on_insert_row = false;
        }     if (_doing_updates) {
    _doing_updates = false;
        }     currentRow = Rows.size() - 1;
        This_Row = (byte[][])Rows.elementAt(currentRow);     return true;
    }
        }
      

  2.   

    但是你要设置ResultSet的属性, 如:       PreparedStatement pstmt = con.prepareStatement(
                                          ResultSet.TYPE_SCROLL_INSENSITIVE,
                                          ResultSet.CONCUR_UPDATABLE);
                  // rs will be scrollable, will not show changes made by others,
           // and will be updatable