ConnectionChecker

Filter pl.aislib.util.web.filters.ConnectionCheckerFilter is responsible for checking if given database is up and working. Filter performs given SQL query and tests if such query finishes without any errors. If error appear upon execution of given query then given action is taken. This filter has few parameters which helps to customize its behaviour. Every parameter for this filter is set by proper entry in web.xml file (<init-param> section).

Actually filter recognizes following parameters:

  • jndi.datasource.name defines source of database being examined. This parameter is required.
  • log.category defines category for all generated logs. If this parameter is ommited then pl.aislib.util.web.filters.connection-checker value is assumed.
  • checking.timeout defines the delay between each database query. If last check was successful then next database test will occur only after given amount of seconds. If parameter is omited 30 second period will be assumed.
  • ping.query defines SQL query executed at every database test. If execution of given query finishes with errors then given action is taken. If this parameter is omitted then filter checks only status of connection with given database. If connection is broken exception is thrown.
  • error.action defines what action is taken when given database is not responding (or given SQL query not finished properly). Possible values:
    • exception occured exception is presented on the screen. This is default action.
    • redirect if error occured user is redirected to the other page.
    • dispatch user is redirected to given page which is relative to the running servlet.
  • exception.message definies message which is displayed when error occured and value of error.action parameter is exception. Default value for this parameter is Could not connect to the database server. Please try again later.
  • redirect.url defines URL address where user will be redirected after error during database test. This parameter is required when value of error.action parameter is redirect.
  • dispatch.url defines URL addres where user will be redirected after error during database test. This address is relative to running servlet. This parameter is required when value of error.action parameter is dispatch.