com.googlecode.jdbw.util
Class ExecuteResultHandlerAdapter

java.lang.Object
  extended by com.googlecode.jdbw.util.ExecuteResultHandlerAdapter
All Implemented Interfaces:
ExecuteResultHandler

public class ExecuteResultHandlerAdapter
extends Object
implements ExecuteResultHandler

This is a convenience class that implements ExecuteResultHandler and provides a default method implementation for this interface. You can then override only the methods that you care about.

Author:
Martin Berglund

Constructor Summary
ExecuteResultHandlerAdapter()
           
 
Method Summary
 int getMaxRowsToFetch()
          This method is called just before the query is sent to the database, setting the property on the Statement which limits the number of rows we want back.
 boolean nextResultSet()
          This method is called in a multi result set query after one result set have been read and another one is coming.
 boolean nextRow(Object[] row)
          The callback is called once for every row returned by a result set.
 void onDone()
          This method is called when all processing of the query is done and the statement is about to be closed.
 void onGeneratedKey(Object object)
          When a key has been generated on the server by the query, this callback is called with that value
 void onResultSet(List<String> columnNames, List<Integer> columnTypes)
          This callback is invoked when a new result set is read from the server, if the result set contains any rows they will appear in subsequent calls to the nextRow(Object[] row) callback.
 void onUpdateCount(int updateCount)
          Callback called for queries that updated rows
 void onWarning(SQLWarning warning)
          Callback called for every SQLWarning the server sent for the query
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExecuteResultHandlerAdapter

public ExecuteResultHandlerAdapter()
Method Detail

getMaxRowsToFetch

public int getMaxRowsToFetch()
Description copied from interface: ExecuteResultHandler
This method is called just before the query is sent to the database, setting the property on the Statement which limits the number of rows we want back. It's up to the driver implementation and the server if this limit will be honored or not (I think)

Specified by:
getMaxRowsToFetch in interface ExecuteResultHandler
Returns:
Number of rows to fetch from the server, 0 means no limit

nextResultSet

public boolean nextResultSet()
Description copied from interface: ExecuteResultHandler
This method is called in a multi result set query after one result set have been read and another one is coming. Expect another call to onResultSet as well, for the next result set.

Specified by:
nextResultSet in interface ExecuteResultHandler
Returns:
true if you want to read the next result set, false if you want to skip remaining result sets and close the statement

nextRow

public boolean nextRow(Object[] row)
Description copied from interface: ExecuteResultHandler
The callback is called once for every row returned by a result set. The row belongs to the result set defined by the last call to onResultSet.

Specified by:
nextRow in interface ExecuteResultHandler
Parameters:
row - All the values of the row
Returns:
true if you want to read more rows, false if you want to close the result set and skip remaining rows

onDone

public void onDone()
Description copied from interface: ExecuteResultHandler
This method is called when all processing of the query is done and the statement is about to be closed.

Specified by:
onDone in interface ExecuteResultHandler

onGeneratedKey

public void onGeneratedKey(Object object)
Description copied from interface: ExecuteResultHandler
When a key has been generated on the server by the query, this callback is called with that value

Specified by:
onGeneratedKey in interface ExecuteResultHandler
Parameters:
object - Generated key value

onResultSet

public void onResultSet(List<String> columnNames,
                        List<Integer> columnTypes)
Description copied from interface: ExecuteResultHandler
This callback is invoked when a new result set is read from the server, if the result set contains any rows they will appear in subsequent calls to the nextRow(Object[] row) callback.

Specified by:
onResultSet in interface ExecuteResultHandler
Parameters:
columnNames - List of all column names
columnTypes - List of all column types (see java.sql.Types)

onUpdateCount

public void onUpdateCount(int updateCount)
Description copied from interface: ExecuteResultHandler
Callback called for queries that updated rows

Specified by:
onUpdateCount in interface ExecuteResultHandler
Parameters:
updateCount - Number of rows affected by the query, as reported by the server

onWarning

public void onWarning(SQLWarning warning)
Description copied from interface: ExecuteResultHandler
Callback called for every SQLWarning the server sent for the query

Specified by:
onWarning in interface ExecuteResultHandler
Parameters:
warning - SQLWarning from the server


Copyright © 2012. All Rights Reserved.