Java SQL ResultSet Read getRowCount(final ResultSet rs)

Here you can find the source of getRowCount(final ResultSet rs)

Description

Get a ResultSet's size.

License

Open Source License

Parameter

Parameter Description
rs ResultSet

Exception

Parameter Description
SQLException on SQL problems

Return

the number of rows in this ResultSet

Declaration

public static int getRowCount(final ResultSet rs) throws SQLException 

Method Source Code


//package com.java2s;
/* JAPI - (Yet another (hopefully) useful) Java API
 *
 * Copyright (C) 2004-2006 Christian Hujer
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA./*from  w w  w .  j  a  v a 2 s.  c  o m*/
 */

import java.sql.ResultSet;

import java.sql.SQLException;

public class Main {
    /** Get a ResultSet's size.
     * Warning: The ResultSet's Cursor is moved by invoking this method!
     * @param rs ResultSet
     * @return the number of rows in this ResultSet
     * @throws SQLException on SQL problems
     */
    public static int getRowCount(final ResultSet rs) throws SQLException {
        return rs.last() ? rs.getRow() : 0;
    }
}

Related

  1. getResultSetValue(ResultSet rs, int index)
  2. getResultSetValue(ResultSet rs, int index, Class requiredType)
  3. getResultSetValue(ResultSet rs, int index, Class requiredType)
  4. getReturnCountInt(ResultSet rs, int column)
  5. getRow(ResultSet rs)
  6. getRowCount(ResultSet set)
  7. getRows(final ResultSet rs)
  8. getRows(ResultSet table)
  9. getRsCloumns(ResultSet rs)