Here you can find the source of getReturnCountInt(ResultSet rs, int column)
Parameter | Description |
---|---|
rs | The <CODE>ResultSet</CODE> returned from the query execution. |
column | The column index in which the return value may be found. |
public static final int getReturnCountInt(ResultSet rs, int column) throws SQLException
//package com.java2s; /*//from ww w. ja va 2 s .c o m * The contents of this file are subject to the Mozilla Public License Version 1.1 * (the "License"); you may not use this file except in compliance with the License. * You may obtain a copy of the License at <http://www.mozilla.org/MPL/>. * * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT * WARRANTY OF ANY KIND, either express or implied. See the License for the specific * language governing rights and limitations under the License. * * The Original Code is the Venice Web Communities System. * * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ import java.sql.*; public class Main { /** * Fetches the return count from a query such as "SELECT COUNT(*) FROM ...". All such queries will always * return at least one row, with the count. * * @param rs The <CODE>ResultSet</CODE> returned from the query execution. * @param column The column index in which the return value may be found. * @return The value of that column (usually, the count you were querying for). * @exception java.sql.SQLException If there was no returned row, or there was a data type mismatch on the column. */ public static final int getReturnCountInt(ResultSet rs, int column) throws SQLException { if (!(rs.next())) throw new SQLException("expected return count row, not present"); return rs.getInt(column); } }