org.springframework.jdbc.core
Class RowCountCallbackHandler


public class RowCountCallbackHandler
implements RowCallbackHandler

Implementation of RowCallbackHandler. Convenient superclass for callback handlers. An instance can only be used once.

We can either use this on its own (for example, in a test case, to ensure that our result sets have valid dimensions), or use it as a superclass for callback handlers that actually do something, and will benefit from the dimension information it provides.

Author:
Rod Johnson
Version: $Id: RowCountCallbackHandler.java,v 1.2 2004/01/02 22:00:54 jhoeller Exp $
Since: May 3, 2001

Method Summary
 final intgetColumnCount()
          Return the number of columns in this result set.
 final String[]getColumnNames()
          Return the names of the columns.
 final int[]getColumnTypes()
          Return the types of the columns as java.sql.Types constants Valid after processRow is invoked the first time.
 final intgetRowCount()
          Return the row count of this ResultSet Only valid after processing is complete
 final voidprocessRow(ResultSet rs)
          Implementation of ResultSetCallbackHandler.

Method Detail

getColumnCount

public final int getColumnCount()
Return the number of columns in this result set. Valid once we've seen the first row, so subclasses can use it during processing
Returns: the number of columns in this result set

getColumnNames

public final String[] getColumnNames()
Return the names of the columns. Valid after processRow is invoked the first time.
Returns: the names of the columns. Indexed from 0 to n-1.

getColumnTypes

public final int[] getColumnTypes()
Return the types of the columns as java.sql.Types constants Valid after processRow is invoked the first time.
Returns: the types of the columns as java.sql.Types constants. Indexed from 0 to n-1.

getRowCount

public final int getRowCount()
Return the row count of this ResultSet Only valid after processing is complete
Returns: the number of rows in this ResultSet

processRow

public final void processRow(ResultSet rs)
throws java.sql.SQLException
Implementation of ResultSetCallbackHandler. Work out column size if this is the first row,* otherwise just count rows.

Subclasses can perform custom extraction or processing by overriding the processRow(ResultSet, int) method.

Association Links

to Class java.lang.String