Class MockPreparedStatement

  • All Implemented Interfaces:
    Verifiable, java.lang.AutoCloseable, java.sql.PreparedStatement, java.sql.Statement, java.sql.Wrapper

    public class MockPreparedStatement
    extends MockObject
    • 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
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addBatch()
      Calls notImplemented.
      void addBatch​(java.lang.String sql)  
      void addExpectedExecute​(java.lang.String queryString, boolean success)  
      void addExpectedExecuteQuery​(java.lang.String queryString, java.sql.ResultSet resultSet)  
      void addExpectedExecuteUpdate​(java.lang.String queryString, int updateCount)  
      void addExpectedSetParameter​(int parameterIndex, int intValue)  
      void addExpectedSetParameter​(int parameterIndex, java.lang.Object parameterValue)  
      void addExpectedSetParameters​(java.lang.Object[] parameters)  
      void addExpectedTargetSQLType​(int aTargetSQLType)  
      void addResultSet​(com.mockobjects.sql.MockResultSet aResultSet)  
      void addUpdateCount​(int count)
      Added value to be returned by executeUpdate()
      void cancel()  
      void clearBatch()  
      void clearParameters()  
      void clearWarnings()  
      void close()  
      boolean execute()
      Calls innerExecute() (see CommonMockStatement).
      boolean execute​(java.lang.String sql)  
      int[] executeBatch()  
      java.sql.ResultSet executeQuery()
      Returns executeQuery(String) with an empty String.
      java.sql.ResultSet executeQuery​(java.lang.String sql)  
      int executeUpdate()
      Returns value set with addUpdateCount
      int executeUpdate​(java.lang.String sql)  
      java.sql.Connection getConnection()  
      int getFetchDirection()  
      int getFetchSize()  
      int getMaxFieldSize()  
      int getMaxRows()  
      java.sql.ResultSetMetaData getMetaData()
      Calls notImplemented.
      boolean getMoreResults()  
      int getQueryTimeout()  
      java.sql.ResultSet getResultSet()  
      int getResultSetConcurrency()  
      int getResultSetType()  
      int getUpdateCount()  
      java.sql.SQLWarning getWarnings()  
      void setArray​(int param, java.sql.Array array)  
      void setAsciiStream​(int param, java.io.InputStream inputStream, int length)
      Calls notImplemented.
      void setBigDecimal​(int param, java.math.BigDecimal bigDecimal)  
      void setBinaryStream​(int param, java.io.InputStream inputStream, int length)
      Calls notImplemented.
      void setBlob​(int param, java.sql.Blob blob)  
      void setBoolean​(int param, boolean aBoolean)  
      void setByte​(int param, byte aByte)  
      void setBytes​(int param, byte[] values)  
      void setCharacterStream​(int param, java.io.Reader reader, int length)
      Calls notImplemented.
      void setClob​(int param, java.sql.Clob clob)  
      void setCursorName​(java.lang.String name)  
      void setDate​(int param, java.sql.Date date)  
      void setDate​(int param, java.sql.Date date, java.util.Calendar calendar)  
      void setDouble​(int param, double aDouble)  
      void setEscapeProcessing​(boolean enable)  
      void setExpectedClearParametersCalls​(int callCount)  
      void setExpectedCloseCalls​(int callCount)  
      void setExpectingNoSetParameters()  
      void setFetchDirection​(int direction)  
      void setFetchSize​(int rows)  
      void setFloat​(int param, float aFloat)  
      void setInt​(int parameterIndex, int x)  
      void setLong​(int param, long aLong)  
      void setMaxFieldSize​(int max)  
      void setMaxRows​(int max)  
      void setNull​(int param, int param1)  
      void setNull​(int param, int param1, java.lang.String typeName)
      Calls notImplemented.
      void setObject​(int param, java.lang.Object anObject)  
      void setObject​(int param, java.lang.Object anObject, int aTargetSQLType)  
      void setObject​(int param, java.lang.Object anObject, int targetSqlType, int scale)
      Calls notImplemented.
      void setQueryTimeout​(int seconds)  
      void setRef​(int param, java.sql.Ref ref)  
      void setShort​(int param, short aShort)  
      void setString​(int parameterIndex, java.lang.String x)  
      void setTime​(int param, java.sql.Time time)  
      void setTime​(int param, java.sql.Time time, java.util.Calendar calendar)  
      void setTimestamp​(int param, java.sql.Timestamp timestamp)  
      void setTimestamp​(int param, java.sql.Timestamp timestamp, java.util.Calendar calendar)
      Calls notImplemented.
      void setUnicodeStream​(int param, java.io.InputStream inputStream, int length)
      Calls notImplemented.
      void setupConnection​(java.sql.Connection conn)  
      void setupThrowExceptionOnExecute​(java.sql.SQLException exception)  
      void setupUpdateCount​(int updateCount)  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.sql.PreparedStatement

        executeLargeUpdate, getParameterMetaData, setAsciiStream, setAsciiStream, setBinaryStream, setBinaryStream, setBlob, setBlob, setCharacterStream, setCharacterStream, setClob, setClob, setNCharacterStream, setNCharacterStream, setNClob, setNClob, setNClob, setNString, setObject, setObject, setRowId, setSQLXML, setURL
      • Methods inherited from interface java.sql.Statement

        addBatch, cancel, clearBatch, clearWarnings, close, closeOnCompletion, enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, execute, execute, execute, execute, executeBatch, executeLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getLargeMaxRows, getLargeUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isClosed, isCloseOnCompletion, isPoolable, isSimpleIdentifier, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setLargeMaxRows, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout
      • Methods inherited from interface java.sql.Wrapper

        isWrapperFor, unwrap
    • Constructor Detail

      • MockPreparedStatement

        public MockPreparedStatement()
    • Method Detail

      • addResultSet

        public void addResultSet​(com.mockobjects.sql.MockResultSet aResultSet)
      • addExpectedSetParameter

        public void addExpectedSetParameter​(int parameterIndex,
                                            int intValue)
      • addExpectedSetParameter

        public void addExpectedSetParameter​(int parameterIndex,
                                            java.lang.Object parameterValue)
      • addExpectedSetParameters

        public void addExpectedSetParameters​(java.lang.Object[] parameters)
      • addExpectedTargetSQLType

        public void addExpectedTargetSQLType​(int aTargetSQLType)
      • setExpectedClearParametersCalls

        public void setExpectedClearParametersCalls​(int callCount)
      • setExpectingNoSetParameters

        public void setExpectingNoSetParameters()
      • clearParameters

        public void clearParameters()
                             throws java.sql.SQLException
        Specified by:
        clearParameters in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • execute

        public boolean execute()
                        throws java.sql.SQLException
        Calls innerExecute() (see CommonMockStatement). Returns false.
        Specified by:
        execute in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • executeQuery

        public java.sql.ResultSet executeQuery()
                                        throws java.sql.SQLException
        Returns executeQuery(String) with an empty String.
        Specified by:
        executeQuery in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • addUpdateCount

        public void addUpdateCount​(int count)
        Added value to be returned by executeUpdate()
        Parameters:
        count -
        See Also:
        PreparedStatement.executeUpdate()
      • executeUpdate

        public int executeUpdate()
                          throws java.sql.SQLException
        Returns value set with addUpdateCount
        Specified by:
        executeUpdate in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
        See Also:
        addUpdateCount(int)
      • setInt

        public void setInt​(int parameterIndex,
                           int x)
                    throws java.sql.SQLException
        Specified by:
        setInt in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setString

        public void setString​(int parameterIndex,
                              java.lang.String x)
                       throws java.sql.SQLException
        Specified by:
        setString in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setTimestamp

        public void setTimestamp​(int param,
                                 java.sql.Timestamp timestamp)
                          throws java.sql.SQLException
        Specified by:
        setTimestamp in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setClob

        public void setClob​(int param,
                            java.sql.Clob clob)
                     throws java.sql.SQLException
        Specified by:
        setClob in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setLong

        public void setLong​(int param,
                            long aLong)
                     throws java.sql.SQLException
        Specified by:
        setLong in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setNull

        public void setNull​(int param,
                            int param1)
                     throws java.sql.SQLException
        Specified by:
        setNull in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setArray

        public void setArray​(int param,
                             java.sql.Array array)
                      throws java.sql.SQLException
        Specified by:
        setArray in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setShort

        public void setShort​(int param,
                             short aShort)
                      throws java.sql.SQLException
        Specified by:
        setShort in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setTime

        public void setTime​(int param,
                            java.sql.Time time,
                            java.util.Calendar calendar)
                     throws java.sql.SQLException
        Specified by:
        setTime in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setObject

        public void setObject​(int param,
                              java.lang.Object anObject,
                              int aTargetSQLType)
                       throws java.sql.SQLException
        Specified by:
        setObject in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setRef

        public void setRef​(int param,
                           java.sql.Ref ref)
                    throws java.sql.SQLException
        Specified by:
        setRef in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setDate

        public void setDate​(int param,
                            java.sql.Date date)
                     throws java.sql.SQLException
        Specified by:
        setDate in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setFloat

        public void setFloat​(int param,
                             float aFloat)
                      throws java.sql.SQLException
        Specified by:
        setFloat in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setBlob

        public void setBlob​(int param,
                            java.sql.Blob blob)
                     throws java.sql.SQLException
        Specified by:
        setBlob in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setDate

        public void setDate​(int param,
                            java.sql.Date date,
                            java.util.Calendar calendar)
                     throws java.sql.SQLException
        Specified by:
        setDate in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setBytes

        public void setBytes​(int param,
                             byte[] values)
                      throws java.sql.SQLException
        Specified by:
        setBytes in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setObject

        public void setObject​(int param,
                              java.lang.Object anObject)
                       throws java.sql.SQLException
        Specified by:
        setObject in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setByte

        public void setByte​(int param,
                            byte aByte)
                     throws java.sql.SQLException
        Specified by:
        setByte in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setDouble

        public void setDouble​(int param,
                              double aDouble)
                       throws java.sql.SQLException
        Specified by:
        setDouble in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setTime

        public void setTime​(int param,
                            java.sql.Time time)
                     throws java.sql.SQLException
        Specified by:
        setTime in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setBoolean

        public void setBoolean​(int param,
                               boolean aBoolean)
                        throws java.sql.SQLException
        Specified by:
        setBoolean in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setBigDecimal

        public void setBigDecimal​(int param,
                                  java.math.BigDecimal bigDecimal)
                           throws java.sql.SQLException
        Specified by:
        setBigDecimal in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • addBatch

        public void addBatch()
                      throws java.sql.SQLException
        Calls notImplemented.
        Specified by:
        addBatch in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setObject

        public void setObject​(int param,
                              java.lang.Object anObject,
                              int targetSqlType,
                              int scale)
                       throws java.sql.SQLException
        Calls notImplemented.
        Specified by:
        setObject in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setCharacterStream

        public void setCharacterStream​(int param,
                                       java.io.Reader reader,
                                       int length)
                                throws java.sql.SQLException
        Calls notImplemented.
        Specified by:
        setCharacterStream in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setAsciiStream

        public void setAsciiStream​(int param,
                                   java.io.InputStream inputStream,
                                   int length)
                            throws java.sql.SQLException
        Calls notImplemented.
        Specified by:
        setAsciiStream in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setBinaryStream

        public void setBinaryStream​(int param,
                                    java.io.InputStream inputStream,
                                    int length)
                             throws java.sql.SQLException
        Calls notImplemented.
        Specified by:
        setBinaryStream in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setNull

        public void setNull​(int param,
                            int param1,
                            java.lang.String typeName)
                     throws java.sql.SQLException
        Calls notImplemented.
        Specified by:
        setNull in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setUnicodeStream

        public void setUnicodeStream​(int param,
                                     java.io.InputStream inputStream,
                                     int length)
                              throws java.sql.SQLException
        Calls notImplemented.
        Specified by:
        setUnicodeStream in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • getMetaData

        public java.sql.ResultSetMetaData getMetaData()
                                               throws java.sql.SQLException
        Calls notImplemented. Returns null.
        Specified by:
        getMetaData in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setTimestamp

        public void setTimestamp​(int param,
                                 java.sql.Timestamp timestamp,
                                 java.util.Calendar calendar)
                          throws java.sql.SQLException
        Calls notImplemented.
        Specified by:
        setTimestamp in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • addExpectedExecuteQuery

        public void addExpectedExecuteQuery​(java.lang.String queryString,
                                            java.sql.ResultSet resultSet)
      • addExpectedExecuteUpdate

        public void addExpectedExecuteUpdate​(java.lang.String queryString,
                                             int updateCount)
      • addExpectedExecute

        public void addExpectedExecute​(java.lang.String queryString,
                                       boolean success)
      • setExpectedCloseCalls

        public void setExpectedCloseCalls​(int callCount)
      • setupConnection

        public void setupConnection​(java.sql.Connection conn)
      • setupThrowExceptionOnExecute

        public void setupThrowExceptionOnExecute​(java.sql.SQLException exception)
      • setupUpdateCount

        public void setupUpdateCount​(int updateCount)
      • close

        public void close()
                   throws java.sql.SQLException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • execute

        public boolean execute​(java.lang.String sql)
                        throws java.sql.SQLException
        Specified by:
        execute in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • executeQuery

        public java.sql.ResultSet executeQuery​(java.lang.String sql)
                                        throws java.sql.SQLException
        Specified by:
        executeQuery in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • executeUpdate

        public int executeUpdate​(java.lang.String sql)
                          throws java.sql.SQLException
        Specified by:
        executeUpdate in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getMaxFieldSize

        public int getMaxFieldSize()
                            throws java.sql.SQLException
        Specified by:
        getMaxFieldSize in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • setMaxFieldSize

        public void setMaxFieldSize​(int max)
                             throws java.sql.SQLException
        Specified by:
        setMaxFieldSize in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getMaxRows

        public int getMaxRows()
                       throws java.sql.SQLException
        Specified by:
        getMaxRows in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • setMaxRows

        public void setMaxRows​(int max)
                        throws java.sql.SQLException
        Specified by:
        setMaxRows in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • setEscapeProcessing

        public void setEscapeProcessing​(boolean enable)
                                 throws java.sql.SQLException
        Specified by:
        setEscapeProcessing in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getQueryTimeout

        public int getQueryTimeout()
                            throws java.sql.SQLException
        Specified by:
        getQueryTimeout in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • setQueryTimeout

        public void setQueryTimeout​(int seconds)
                             throws java.sql.SQLException
        Specified by:
        setQueryTimeout in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • cancel

        public void cancel()
                    throws java.sql.SQLException
        Specified by:
        cancel in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getWarnings

        public java.sql.SQLWarning getWarnings()
                                        throws java.sql.SQLException
        Specified by:
        getWarnings in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • clearWarnings

        public void clearWarnings()
                           throws java.sql.SQLException
        Specified by:
        clearWarnings in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • setCursorName

        public void setCursorName​(java.lang.String name)
                           throws java.sql.SQLException
        Specified by:
        setCursorName in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getResultSet

        public java.sql.ResultSet getResultSet()
                                        throws java.sql.SQLException
        Specified by:
        getResultSet in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getUpdateCount

        public int getUpdateCount()
                           throws java.sql.SQLException
        Specified by:
        getUpdateCount in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getMoreResults

        public boolean getMoreResults()
                               throws java.sql.SQLException
        Specified by:
        getMoreResults in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • setFetchDirection

        public void setFetchDirection​(int direction)
                               throws java.sql.SQLException
        Specified by:
        setFetchDirection in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getFetchDirection

        public int getFetchDirection()
                              throws java.sql.SQLException
        Specified by:
        getFetchDirection in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • setFetchSize

        public void setFetchSize​(int rows)
                          throws java.sql.SQLException
        Specified by:
        setFetchSize in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getFetchSize

        public int getFetchSize()
                         throws java.sql.SQLException
        Specified by:
        getFetchSize in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getResultSetConcurrency

        public int getResultSetConcurrency()
                                    throws java.sql.SQLException
        Specified by:
        getResultSetConcurrency in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getResultSetType

        public int getResultSetType()
                             throws java.sql.SQLException
        Specified by:
        getResultSetType in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • addBatch

        public void addBatch​(java.lang.String sql)
                      throws java.sql.SQLException
        Specified by:
        addBatch in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • clearBatch

        public void clearBatch()
                        throws java.sql.SQLException
        Specified by:
        clearBatch in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • executeBatch

        public int[] executeBatch()
                           throws java.sql.SQLException
        Specified by:
        executeBatch in interface java.sql.Statement
        Throws:
        java.sql.SQLException
      • getConnection

        public java.sql.Connection getConnection()
                                          throws java.sql.SQLException
        Specified by:
        getConnection in interface java.sql.Statement
        Throws:
        java.sql.SQLException