Class PreparedStatementExecutor


  • public class PreparedStatementExecutor
    extends Object
    Provide a utility to execute PreparedStatements.
    • Constructor Detail

      • PreparedStatementExecutor

        public PreparedStatementExecutor()
        Create a PreparedStatementExecutor.
      • PreparedStatementExecutor

        public PreparedStatementExecutor​(Connection connection)
        Create a PreparedStatementExecutor which will use the given connection. The provided connection will not be closed after the query has been executed.
        Parameters:
        connection - the database connection to use
    • Method Detail

      • executeQuery

        public void executeQuery​(String sqlStatement,
                                 ResultSetProcessor resultSetProcessor)
        Execute the sql statement and the result is handled by the processor.
        Parameters:
        sqlStatement - sql statement
        resultSetProcessor - the result set processor
      • executeQuery

        public void executeQuery​(String sqlStatement,
                                 String[] args,
                                 ResultSetProcessor resultSetProcessor)
        Execute the sql statement with list of arguments and the result is handled by the processor.
        Parameters:
        sqlStatement - sql statement
        args - arguments for the prepared statement
        resultSetProcessor - the result set processor
      • executeUpdate

        public int executeUpdate​(String sqlStatement,
                                 Object[] args)
        Execute the sql statement with list of arguments and the result is handled by the processor.
        Parameters:
        sqlStatement - sql statement (required)
        args - arguments for the prepared statement
        Returns:
        number of rows updated.