Class DatabaseQueryResourceScheduledTask
java.lang.Object
com.orchestranetworks.scheduler.ScheduledTask
com.apgar.common.lib.scheduledtask.DatabaseQueryResourceScheduledTask
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute(ScheduledExecutionContext context) Executes the scheduled task.Gets the JNDI resource name of the database.intGets the number of times the query will be executed.voidsetDatabaseName(String databaseName) Sets the JNDI resource name of the database.voidsetRequestCount(int requestCount) Sets the number of times the query should be executed.Methods inherited from class com.orchestranetworks.scheduler.ScheduledTask
handleBeforeInterrupting, handleBeforePausing, handleBeforeResuming, isInterruptable, isPausable, validate, zza, zza, zza, zzb, zzb, zzc, zzd
-
Constructor Details
-
DatabaseQueryResourceScheduledTask
public DatabaseQueryResourceScheduledTask()
-
-
Method Details
-
getDatabaseName
Gets the JNDI resource name of the database.- Returns:
- the database JNDI resource name
-
setDatabaseName
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
public void execute(ScheduledExecutionContext context) throws OperationException, ScheduledTaskInterruption Executes the scheduled task.Performs the following steps:
- Logs the database name and request count to the execution context.
- Obtains the
DataSourcevia JNDI lookup using the provided database name. - Executes the query
SELECT * FROM EBX_REPfor the specified request count.
If an error occurs during lookup or query execution, the error is logged at
Level.SEVEREand recorded in the execution context.- Specified by:
executein classScheduledTask- Parameters:
context- the scheduled execution context- Throws:
OperationException- if an EBX-specific operation failsScheduledTaskInterruption- if the task execution is interrupted
-