Class PreparedStatementHelper


  • public class PreparedStatementHelper
    extends java.lang.Object
    Collection of utility functions to simply setting values on a PreparedStatement
    • Constructor Summary

      Constructors 
      Constructor Description
      PreparedStatementHelper​(java.sql.PreparedStatement ps)
      Public constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addBatch()
      Add a new batch entry based on the current state of the PreparedStatement.
      int registerOutParameter​(int parameterType)
      Register an OUT parameter, assuming the delegate is a CallableStatement
      PreparedStatementHelper setBinaryStream​(java.io.InputStream value)
      Set the (possibly null) InputStream value at the current position and increment the position by 1
      PreparedStatementHelper setInt​(java.lang.Integer value)
      Set the (possibly null) int value at the current position and increment the position by 1
      PreparedStatementHelper setLong​(java.lang.Long value)
      Set the (possibly null) long value at the current position and increment the position by 1
      PreparedStatementHelper setShort​(java.lang.Short value)
      Set the (possibly null) long value at the current position and increment the position by 1
      PreparedStatementHelper setString​(java.lang.String value)
      Set the (possibly null) String value at the current position and increment the position by 1
      PreparedStatementHelper setTimestamp​(java.sql.Timestamp value)
      Set the (possibly null) int value at the current position and increment the position by 1
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PreparedStatementHelper

        public PreparedStatementHelper​(java.sql.PreparedStatement ps)
        Public constructor
        Parameters:
        ps -
    • Method Detail

      • setInt

        public PreparedStatementHelper setInt​(java.lang.Integer value)
                                       throws java.sql.SQLException
        Set the (possibly null) int value at the current position and increment the position by 1
        Parameters:
        value -
        Returns:
        this instance
        Throws:
        java.sql.SQLException
      • setLong

        public PreparedStatementHelper setLong​(java.lang.Long value)
                                        throws java.sql.SQLException
        Set the (possibly null) long value at the current position and increment the position by 1
        Parameters:
        value -
        Returns:
        this instance
        Throws:
        java.sql.SQLException
      • setShort

        public PreparedStatementHelper setShort​(java.lang.Short value)
                                         throws java.sql.SQLException
        Set the (possibly null) long value at the current position and increment the position by 1
        Parameters:
        value -
        Returns:
        this instance
        Throws:
        java.sql.SQLException
      • setString

        public PreparedStatementHelper setString​(java.lang.String value)
                                          throws java.sql.SQLException
        Set the (possibly null) String value at the current position and increment the position by 1
        Parameters:
        value -
        Returns:
        this instance
        Throws:
        java.sql.SQLException
      • setBinaryStream

        public PreparedStatementHelper setBinaryStream​(java.io.InputStream value)
                                                throws java.sql.SQLException
        Set the (possibly null) InputStream value at the current position and increment the position by 1
        Parameters:
        value -
        Returns:
        this instance
        Throws:
        java.sql.SQLException
      • setTimestamp

        public PreparedStatementHelper setTimestamp​(java.sql.Timestamp value)
                                             throws java.sql.SQLException
        Set the (possibly null) int value at the current position and increment the position by 1
        Parameters:
        value -
        Returns:
        this instance
        Throws:
        java.sql.SQLException
      • registerOutParameter

        public int registerOutParameter​(int parameterType)
                                 throws java.sql.SQLException
        Register an OUT parameter, assuming the delegate is a CallableStatement
        Parameters:
        parameterType - from Types
        Returns:
        the parameter index of the OUT parameter
        Throws:
        java.sql.SQLException
      • addBatch

        public void addBatch()
                      throws java.sql.SQLException
        Add a new batch entry based on the current state of the PreparedStatement. Note that we don't return this on purpose...because addBatch should be last in any sequence of setXX(...) calls.
        Throws:
        java.sql.SQLException