Class DBConnectionFilter

All Implemented Interfaces:
RequestAccess

public class DBConnectionFilter extends AppControllerFilter
Class is to be used in web apps that use ActiveJDBC. This class will open a connection configured in DBConfig class of the application before controller is executed and will close it after.
Author:
Igor Polevoy
  • Constructor Details

    • DBConnectionFilter

      public DBConnectionFilter()
      This constructor is used to open all configured connections for a current environment.
    • DBConnectionFilter

      public DBConnectionFilter(String dbName)
      Use this constructor to only open a named DB connection for a given environment.
      Parameters:
      dbName - name of DB to open
    • DBConnectionFilter

      public DBConnectionFilter(String dbName, boolean manageTransaction)
      Use this constructor to only open a named DB connection for a given environment and specify if this filter needs to manage transactions.
      Parameters:
      dbName - name of DB to open
      manageTransaction - if set to true, the filter will start a transaction inside before() method, commit inside the after() method, and rollback inside onException(Exception) method. This applies to all connections managed by this filter. If set to false, transactions are not managed. Configuration of J2EE container transaction management for a given JNDI DataSource can interfere with this filter. This filter uses simple java.sql.Connection methods: setAutocommit(boolean), commit() and rollback(). If you configure XA transactions, this parameter could be completely ignored by the container itself. For this filter to manage transactions, the datasources should not be type of XA. Read container documentation.
  • Method Details