Class DefaultStatementBuilder

  • All Implemented Interfaces:
    StatementBuilder

    public class DefaultStatementBuilder
    extends java.lang.Object
    implements StatementBuilder
    A StatementBuilder which will always create a new PreparedStatement.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close​(java.sql.Connection conn, java.lang.String sql, java.sql.Statement stmt)
      Called to close an individual prepared statement created from this builder.
      java.sql.PreparedStatement create​(java.sql.Connection conn, java.lang.String sql, StatementContext ctx)
      Create a new DefaultStatementBuilder which will always create a new PreparedStatement from the Connection
      java.sql.Statement create​(java.sql.Connection conn, StatementContext ctx)
      Called each time a statement needs to be created.
      java.sql.CallableStatement createCall​(java.sql.Connection conn, java.lang.String sql, StatementContext ctx)
      Called each time a Callable statement needs to be created
      • Methods inherited from class java.lang.Object

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

      • DefaultStatementBuilder

        public DefaultStatementBuilder()
    • Method Detail

      • create

        public java.sql.Statement create​(java.sql.Connection conn,
                                         StatementContext ctx)
                                  throws java.sql.SQLException
        Description copied from interface: StatementBuilder
        Called each time a statement needs to be created.
        Specified by:
        create in interface StatementBuilder
        Parameters:
        conn - the JDBC Connection the statement is being created for
        ctx - Statement context associated with the SqlStatement this is building for
        Returns:
        a Statement
        Throws:
        java.sql.SQLException - if anything goes wrong getting the statement
      • create

        public java.sql.PreparedStatement create​(java.sql.Connection conn,
                                                 java.lang.String sql,
                                                 StatementContext ctx)
                                          throws java.sql.SQLException
        Create a new DefaultStatementBuilder which will always create a new PreparedStatement from the Connection
        Specified by:
        create in interface StatementBuilder
        Parameters:
        conn - Used to prepare the statement
        sql - Translated SQL statement
        ctx - Unused
        Returns:
        a new PreparedStatement
        Throws:
        java.sql.SQLException - if anything goes wrong preparing the statement
      • close

        public void close​(java.sql.Connection conn,
                          java.lang.String sql,
                          java.sql.Statement stmt)
                   throws java.sql.SQLException
        Called to close an individual prepared statement created from this builder. In this case, it closes immediately.
        Specified by:
        close in interface StatementBuilder
        Parameters:
        sql - the translated SQL which was prepared
        stmt - the statement
        conn - the JDBC Connection that this statement was created for.
        Throws:
        java.sql.SQLException - if anything goes wrong closing the statement
      • createCall

        public java.sql.CallableStatement createCall​(java.sql.Connection conn,
                                                     java.lang.String sql,
                                                     StatementContext ctx)
                                              throws java.sql.SQLException
        Called each time a Callable statement needs to be created
        Specified by:
        createCall in interface StatementBuilder
        Parameters:
        conn - the JDBC Connection the statement is being created for
        sql - the translated SQL which should be prepared
        ctx - Statement context associated with the SqlStatement this is building for
        Returns:
        a CallableStatement for the given arguments
        Throws:
        java.sql.SQLException - if anything goes wrong preparing the statement