Class ChangelogJdbcMdcListener


  • public class ChangelogJdbcMdcListener
    extends Object
    A wrapper utility class around the standard JdbcExecutor used to monitor and log sql from Jdbc queries
    • Constructor Detail

      • ChangelogJdbcMdcListener

        public ChangelogJdbcMdcListener()
    • Method Detail

      • execute

        public static void execute​(Database database,
                                   ChangelogJdbcMdcListener.ExecuteJdbc jdbcQuery)
                            throws DatabaseException
        Execute the given statement via the jdbc executor. Adds MDC of the statement sql and outcome to logging.
        Parameters:
        database - the database to execute against
        jdbcQuery - the executor function to apply
        Throws:
        DatabaseException - if there was a problem running the sql statement
      • query

        public static <T> T query​(Database database,
                                  ChangelogJdbcMdcListener.QueryJdbc<T> jdbcQuery)
                           throws DatabaseException
        Execute the given statement via the jdbc executor. Adds MDC of the statement sql and outcome to logging.
        Parameters:
        database - the database to execute against
        jdbcQuery - the executor function to apply
        Returns:
        the result of the executor function
        Throws:
        DatabaseException - if there was a problem running the sql statement