net.sourceforge.sqlunit.test.mock
Class SQLUnitMockStatement

java.lang.Object
  extended by com.mockrunner.mock.jdbc.MockStatement
      extended by net.sourceforge.sqlunit.test.mock.SQLUnitMockStatement
All Implemented Interfaces:
java.sql.Statement

public class SQLUnitMockStatement
extends com.mockrunner.mock.jdbc.MockStatement

Overrides certain methods in the MockStatement class for mock testing of SQLUnit.

Version:
$Revision: 1.7 $
Author:
Sujit Pal (spal@users.sourceforge.net)

Field Summary
 
Fields inherited from interface java.sql.Statement
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO
 
Constructor Summary
SQLUnitMockStatement(java.sql.Connection conn)
          Instantiates a SQLUnitMockStatement object using a Connection.
 
Method Summary
 boolean execute(java.lang.String sql)
          Overrides the execute(String) method in MockStatement.
 boolean getMoreResults(java.lang.String sql)
          Returns true if there are more result sets available for this SQL.
 java.sql.ResultSet getResultSet()
          Returns the current result set from the SQL statement.
 int getUpdateCount()
          Returns the update count.
 void setResultSetHandler(com.mockrunner.jdbc.AbstractResultSetHandler aHandler)
          Sets the IntrospectingStatementResultSetHandler for the MockStatement.
 
Methods inherited from class com.mockrunner.mock.jdbc.MockStatement
addBatch, cancel, clearBatch, clearWarnings, cloneResultSet, close, execute, execute, execute, executeBatch, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getCursorName, getFetchDirection, getFetchSize, getGeneratedKeys, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getWarnings, isClosed, isQuery, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setNextResultSet, setNextUpdateCount, setQueryTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLUnitMockStatement

public SQLUnitMockStatement(java.sql.Connection conn)
Instantiates a SQLUnitMockStatement object using a Connection.

Parameters:
conn - a Connection object.
Method Detail

setResultSetHandler

public final void setResultSetHandler(com.mockrunner.jdbc.AbstractResultSetHandler aHandler)
Sets the IntrospectingStatementResultSetHandler for the MockStatement.

Overrides:
setResultSetHandler in class com.mockrunner.mock.jdbc.MockStatement
Parameters:
aHandler - an IntrospectingStatementResultSetHandler object.

getMoreResults

public final boolean getMoreResults(java.lang.String sql)
                             throws java.sql.SQLException
Returns true if there are more result sets available for this SQL.

Parameters:
sql - the SQL to look up.
Returns:
true if there are more result sets available, else false.
Throws:
java.sql.SQLException - if one is thrown.

getResultSet

public final java.sql.ResultSet getResultSet()
                                      throws java.sql.SQLException
Returns the current result set from the SQL statement.

Specified by:
getResultSet in interface java.sql.Statement
Overrides:
getResultSet in class com.mockrunner.mock.jdbc.MockStatement
Returns:
a MockResultSet object.
Throws:
java.sql.SQLException - if one is thrown.

execute

public final boolean execute(java.lang.String sql)
                      throws java.sql.SQLException
Overrides the execute(String) method in MockStatement. Introspects the named method to pull the current resultset out.

Specified by:
execute in interface java.sql.Statement
Overrides:
execute in class com.mockrunner.mock.jdbc.MockStatement
Parameters:
sql - the SQL string to execute.
Returns:
true if there are resultsets available.
Throws:
java.sql.SQLException - if there was a problem.

getUpdateCount

public final int getUpdateCount()
                         throws java.sql.SQLException
Returns the update count.

Specified by:
getUpdateCount in interface java.sql.Statement
Overrides:
getUpdateCount in class com.mockrunner.mock.jdbc.MockStatement
Returns:
the update count.
Throws:
java.sql.SQLException - if an error occurs.