Class DatabaseQueryResourceScheduledTask

java.lang.Object
com.orchestranetworks.scheduler.ScheduledTask
com.apgar.common.lib.scheduledtask.DatabaseQueryResourceScheduledTask

public class DatabaseQueryResourceScheduledTask extends ScheduledTask
A scheduled task that executes a simple database query using a DataSource obtained via JNDI lookup.

This task is useful for performance testing and validating that the configured JNDI database resource is available and responsive. The query SELECT * FROM EBX_REP is executed multiple times based on the configured request count.

To utilize this functionality, create a task in the Tasks table of the Task Scheduler under the Administration tab with the following specifications:

  • Module: The module that contains this JAR file.
  • Class Name: com.apgar.common.lib.scheduledtask.DatabaseQueryResourceScheduledTask
  • Parameters:
    • databaseName: Specifies the name of the database JNDI resource.
    • requestCount: Specifies the number of times to execute the query.

The execution report will include the configured parameters as well as any errors encountered during JNDI lookup or query execution.

Author:
APGAR Consulting
  • Constructor Details

    • DatabaseQueryResourceScheduledTask

      public DatabaseQueryResourceScheduledTask()
  • Method Details

    • getDatabaseName

      public String getDatabaseName()
      Gets the JNDI resource name of the database.
      Returns:
      the database JNDI resource name
    • setDatabaseName

      public void setDatabaseName(String databaseName)
      Sets the JNDI resource name of the database.
      Parameters:
      databaseName - the JNDI resource name (e.g., "jdbc/MyDataSource")
    • getRequestCount

      public int getRequestCount()
      Gets the number of times the query will be executed.
      Returns:
      the request count
    • setRequestCount

      public void setRequestCount(int requestCount)
      Sets the number of times the query should be executed.
      Parameters:
      requestCount - the number of queries to execute
    • execute

      Executes the scheduled task.

      Performs the following steps:

      1. Logs the database name and request count to the execution context.
      2. Obtains the DataSource via JNDI lookup using the provided database name.
      3. Executes the query SELECT * FROM EBX_REP for the specified request count.

      If an error occurs during lookup or query execution, the error is logged at Level.SEVERE and recorded in the execution context.

      Specified by:
      execute in class ScheduledTask
      Parameters:
      context - the scheduled execution context
      Throws:
      OperationException - if an EBX-specific operation fails
      ScheduledTaskInterruption - if the task execution is interrupted