org.quartz.impl.jdbcjobstore
Class StdJDBCDelegate

java.lang.Object
  extended by org.quartz.impl.jdbcjobstore.StdJDBCDelegate
All Implemented Interfaces:
Constants, DriverDelegate, StdJDBCConstants
Direct Known Subclasses:
CacheDelegate, CUBRIDDelegate, DB2v6Delegate, DB2v7Delegate, DB2v8Delegate, HSQLDBDelegate, MSSQLDelegate, OracleDelegate, PointbaseDelegate, PostgreSQLDelegate, SybaseDelegate, WebLogicDelegate

public class StdJDBCDelegate
extends Object
implements DriverDelegate, StdJDBCConstants

This is meant to be an abstract base class for most, if not all, DriverDelegate implementations. Subclasses should override only those methods that need special handling for the DBMS driver in question.

Author:
Jeffrey Wescott, James House, Eric Mueller

Field Summary
protected  ClassLoadHelper classLoadHelper
           
protected  String instanceId
           
protected  org.slf4j.Logger logger
           
protected  String schedName
           
protected  String tablePrefix
           
protected  List<TriggerPersistenceDelegate> triggerPersistenceDelegates
           
protected  boolean useProperties
           
 
Fields inherited from interface org.quartz.impl.jdbcjobstore.StdJDBCConstants
COUNT_MISFIRED_TRIGGERS_IN_STATE, DELETE_ALL_BLOB_TRIGGERS, DELETE_ALL_CALENDARS, DELETE_ALL_CRON_TRIGGERS, DELETE_ALL_JOB_DETAILS, DELETE_ALL_PAUSED_TRIGGER_GRPS, DELETE_ALL_SIMPLE_TRIGGERS, DELETE_ALL_SIMPROP_TRIGGERS, DELETE_ALL_TRIGGERS, DELETE_BLOB_TRIGGER, DELETE_CALENDAR, DELETE_CRON_TRIGGER, DELETE_FIRED_TRIGGER, DELETE_FIRED_TRIGGERS, DELETE_INSTANCES_FIRED_TRIGGERS, DELETE_JOB_DETAIL, DELETE_NO_RECOVERY_FIRED_TRIGGERS, DELETE_PAUSED_TRIGGER_GROUP, DELETE_PAUSED_TRIGGER_GROUPS, DELETE_SCHEDULER_STATE, DELETE_SIMPLE_TRIGGER, DELETE_TRIGGER, INSERT_BLOB_TRIGGER, INSERT_CALENDAR, INSERT_CRON_TRIGGER, INSERT_FIRED_TRIGGER, INSERT_JOB_DETAIL, INSERT_PAUSED_TRIGGER_GROUP, INSERT_SCHEDULER_STATE, INSERT_SIMPLE_TRIGGER, INSERT_TRIGGER, SCHED_NAME_SUBST, SELECT_BLOB_TRIGGER, SELECT_CALENDAR, SELECT_CALENDAR_EXISTENCE, SELECT_CALENDARS, SELECT_CRON_TRIGGER, SELECT_FIRED_TRIGGER, SELECT_FIRED_TRIGGER_GROUP, SELECT_FIRED_TRIGGER_INSTANCE_NAMES, SELECT_FIRED_TRIGGERS, SELECT_FIRED_TRIGGERS_OF_JOB, SELECT_FIRED_TRIGGERS_OF_JOB_GROUP, SELECT_HAS_MISFIRED_TRIGGERS_IN_STATE, SELECT_INSTANCES_FIRED_TRIGGERS, SELECT_INSTANCES_RECOVERABLE_FIRED_TRIGGERS, SELECT_JOB_DETAIL, SELECT_JOB_EXECUTION_COUNT, SELECT_JOB_EXISTENCE, SELECT_JOB_FOR_TRIGGER, SELECT_JOB_GROUPS, SELECT_JOB_NONCONCURRENT, SELECT_JOBS_IN_GROUP, SELECT_JOBS_IN_GROUP_LIKE, SELECT_MISFIRED_TRIGGERS, SELECT_MISFIRED_TRIGGERS_IN_GROUP_IN_STATE, SELECT_MISFIRED_TRIGGERS_IN_STATE, SELECT_NEXT_FIRE_TIME, SELECT_NEXT_TRIGGER_TO_ACQUIRE, SELECT_NUM_CALENDARS, SELECT_NUM_JOBS, SELECT_NUM_TRIGGERS, SELECT_NUM_TRIGGERS_FOR_JOB, SELECT_NUM_TRIGGERS_IN_GROUP, SELECT_PAUSED_TRIGGER_GROUP, SELECT_PAUSED_TRIGGER_GROUPS, SELECT_REFERENCED_CALENDAR, SELECT_SCHEDULER_STATE, SELECT_SCHEDULER_STATES, SELECT_SIMPLE_TRIGGER, SELECT_TRIGGER, SELECT_TRIGGER_DATA, SELECT_TRIGGER_EXISTENCE, SELECT_TRIGGER_FOR_FIRE_TIME, SELECT_TRIGGER_GROUPS, SELECT_TRIGGER_GROUPS_FILTERED, SELECT_TRIGGER_STATE, SELECT_TRIGGER_STATUS, SELECT_TRIGGERS_FOR_CALENDAR, SELECT_TRIGGERS_FOR_JOB, SELECT_TRIGGERS_IN_GROUP, SELECT_TRIGGERS_IN_GROUP_LIKE, SELECT_TRIGGERS_IN_STATE, TABLE_PREFIX_SUBST, UPDATE_BLOB_TRIGGER, UPDATE_CALENDAR, UPDATE_CRON_TRIGGER, UPDATE_FIRED_TRIGGER, UPDATE_JOB_DATA, UPDATE_JOB_DETAIL, UPDATE_JOB_TRIGGER_STATES, UPDATE_JOB_TRIGGER_STATES_FROM_OTHER_STATE, UPDATE_SCHEDULER_STATE, UPDATE_SIMPLE_TRIGGER, UPDATE_TRIGGER, UPDATE_TRIGGER_GROUP_STATE_FROM_STATE, UPDATE_TRIGGER_GROUP_STATE_FROM_STATES, UPDATE_TRIGGER_SKIP_DATA, UPDATE_TRIGGER_STATE, UPDATE_TRIGGER_STATE_FROM_STATE, UPDATE_TRIGGER_STATE_FROM_STATES, UPDATE_TRIGGER_STATES_FROM_OTHER_STATES
 
Fields inherited from interface org.quartz.impl.jdbcjobstore.Constants
ALIAS_COL_NEXT_FIRE_TIME, ALL_GROUPS_PAUSED, COL_BLOB, COL_CALENDAR, COL_CALENDAR_NAME, COL_CHECKIN_INTERVAL, COL_CRON_EXPRESSION, COL_DESCRIPTION, COL_END_TIME, COL_ENTRY_ID, COL_ENTRY_STATE, COL_FIRED_TIME, COL_INSTANCE_NAME, COL_IS_DURABLE, COL_IS_NONCONCURRENT, COL_IS_UPDATE_DATA, COL_IS_VOLATILE, COL_JOB_CLASS, COL_JOB_DATAMAP, COL_JOB_GROUP, COL_JOB_NAME, COL_LAST_CHECKIN_TIME, COL_LOCK_NAME, COL_MISFIRE_INSTRUCTION, COL_NEXT_FIRE_TIME, COL_PREV_FIRE_TIME, COL_PRIORITY, COL_REPEAT_COUNT, COL_REPEAT_INTERVAL, COL_REQUESTS_RECOVERY, COL_SCHED_TIME, COL_SCHEDULER_NAME, COL_START_TIME, COL_TIME_ZONE_ID, COL_TIMES_TRIGGERED, COL_TRIGGER_GROUP, COL_TRIGGER_NAME, COL_TRIGGER_STATE, COL_TRIGGER_TYPE, DEFAULT_TABLE_PREFIX, STATE_ACQUIRED, STATE_BLOCKED, STATE_COMPLETE, STATE_DELETED, STATE_ERROR, STATE_EXECUTING, STATE_MISFIRED, STATE_PAUSED, STATE_PAUSED_BLOCKED, STATE_WAITING, TABLE_BLOB_TRIGGERS, TABLE_CALENDARS, TABLE_CRON_TRIGGERS, TABLE_FIRED_TRIGGERS, TABLE_JOB_DETAILS, TABLE_LOCKS, TABLE_PAUSED_TRIGGERS, TABLE_SCHEDULER_STATE, TABLE_SIMPLE_TRIGGERS, TABLE_TRIGGERS, TTYPE_BLOB, TTYPE_CAL_INT, TTYPE_CRON, TTYPE_DAILY_TIME_INT, TTYPE_SIMPLE
 
Constructor Summary
StdJDBCDelegate()
           Create new StdJDBCDelegate instance.
 
Method Summary
protected  void addDefaultTriggerPersistenceDelegates()
           
 void addTriggerPersistenceDelegate(TriggerPersistenceDelegate delegate)
           
 boolean calendarExists(Connection conn, String calendarName)
           Check whether or not a calendar exists.
 boolean calendarIsReferenced(Connection conn, String calendarName)
           Check whether or not a calendar is referenced by any triggers.
protected  boolean canUseProperties()
           
 void clearData(Connection conn)
          Clear (delete!) all scheduling data - all Jobs, Triggers Calendars.
protected static void closeResultSet(ResultSet rs)
          Cleanup helper method that closes the given ResultSet while ignoring any errors.
protected static void closeStatement(Statement statement)
          Cleanup helper method that closes the given Statement while ignoring any errors.
protected  Map<?,?> convertFromProperty(Properties properties)
          convert the JobDataMap into a list of properties
protected  Properties convertToProperty(Map<?,?> data)
          convert the JobDataMap into a list of properties
 int countMisfiredTriggersInState(Connection conn, String state1, long ts)
           Get the number of triggers in the given states that have misfired - according to the given timestamp.
 int deleteAllPausedTriggerGroups(Connection conn)
           
 int deleteBlobTrigger(Connection conn, TriggerKey triggerKey)
           Delete the cron trigger data for a trigger.
 int deleteCalendar(Connection conn, String calendarName)
           Delete a calendar.
 int deleteFiredTrigger(Connection conn, String entryId)
           Delete a fired trigger.
 int deleteFiredTriggers(Connection conn)
           Delete all fired triggers.
 int deleteFiredTriggers(Connection conn, String theInstanceId)
           Delete all fired triggers of the given instance.
 int deleteJobDetail(Connection conn, JobKey jobKey)
           Delete the job detail record for the given job.
 int deletePausedTriggerGroup(Connection conn, GroupMatcher<TriggerKey> matcher)
           
 int deletePausedTriggerGroup(Connection conn, String groupName)
           
 int deleteSchedulerState(Connection conn, String theInstanceId)
           Delete a scheduler-instance state record.
 int deleteTrigger(Connection conn, TriggerKey triggerKey)
           Delete the base trigger data for a trigger.
protected  void deleteTriggerExtension(Connection conn, TriggerKey triggerKey)
           
 TriggerPersistenceDelegate findTriggerPersistenceDelegate(OperableTrigger trigger)
           
 TriggerPersistenceDelegate findTriggerPersistenceDelegate(String discriminator)
           
protected  boolean getBoolean(ResultSet rs, int columnIndex)
          Retrieves the value of the designated column index in the current row as a boolean.
protected  boolean getBoolean(ResultSet rs, String columnName)
          Retrieves the value of the designated column in the current row as a boolean.
protected  Object getJobDataFromBlob(ResultSet rs, String colName)
           This method should be overridden by any delegate subclasses that need special handling for BLOBs for job details.
protected  Object getKeyOfNonSerializableValue(Map<?,?> data)
          Find the key of the first non-serializable value in the given Map.
protected  Object getObjectFromBlob(ResultSet rs, String colName)
           This method should be overridden by any delegate subclasses that need special handling for BLOBs.
protected  String getSchedulerNameLiteral()
           
 boolean hasMisfiredTriggersInState(Connection conn, String state1, long ts, int count, List<TriggerKey> resultList)
           Get the names of all of the triggers in the given state that have misfired - according to the given timestamp.
 void initialize(org.slf4j.Logger logger, String tablePrefix, String schedName, String instanceId, ClassLoadHelper classLoadHelper, boolean useProperties, String initString)
           
 int insertBlobTrigger(Connection conn, OperableTrigger trigger)
           Insert the blob trigger data.
 int insertCalendar(Connection conn, String calendarName, Calendar calendar)
           Insert a new calendar.
 int insertFiredTrigger(Connection conn, OperableTrigger trigger, String state, JobDetail job)
           Insert a fired trigger.
 int insertJobDetail(Connection conn, JobDetail job)
           Insert the job detail record.
 int insertPausedTriggerGroup(Connection conn, String groupName)
           
 int insertSchedulerState(Connection conn, String theInstanceId, long checkInTime, long interval)
           Insert a scheduler-instance state record.
 int insertTrigger(Connection conn, OperableTrigger trigger, String state, JobDetail jobDetail)
           Insert the base trigger data.
 boolean isExistingTriggerGroup(Connection conn, String groupName)
           
 boolean isJobNonConcurrent(Connection conn, JobKey jobKey)
           Check whether or not the given job is stateful.
protected  boolean isMatcherEquals(GroupMatcher<?> matcher)
           
 boolean isTriggerGroupPaused(Connection conn, String groupName)
           
 boolean jobExists(Connection conn, JobKey jobKey)
           Check whether or not the given job exists.
protected  String rtp(String query)
           Replace the table prefix in a query by replacing any occurrences of "{0}" with the table prefix.
 Calendar selectCalendar(Connection conn, String calendarName)
           Select a calendar.
 List<String> selectCalendars(Connection conn)
           Select all of the stored calendars.
 Set<String> selectFiredTriggerInstanceNames(Connection conn)
           Select the distinct instance names of all fired-trigger records.
 List<FiredTriggerRecord> selectFiredTriggerRecords(Connection conn, String triggerName, String groupName)
           Select the states of all fired-trigger records for a given trigger, or trigger group if trigger name is null.
 List<FiredTriggerRecord> selectFiredTriggerRecordsByJob(Connection conn, String jobName, String groupName)
           Select the states of all fired-trigger records for a given job, or job group if job name is null.
 List<FiredTriggerRecord> selectInstancesFiredTriggerRecords(Connection conn, String instanceName)
           Select the states of all fired-trigger records for a given scheduler instance.
 JobDetail selectJobDetail(Connection conn, JobKey jobKey, ClassLoadHelper loadHelper)
           Select the JobDetail object for a given job name / group name.
 int selectJobExecutionCount(Connection conn, JobKey jobKey)
           Get the number instances of the identified job currently executing.
 JobDetail selectJobForTrigger(Connection conn, ClassLoadHelper loadHelper, TriggerKey triggerKey)
           Select the job to which the trigger is associated.
 JobDetail selectJobForTrigger(Connection conn, ClassLoadHelper loadHelper, TriggerKey triggerKey, boolean loadJobClass)
           Select the job to which the trigger is associated.
 List<String> selectJobGroups(Connection conn)
           Select all of the job group names that are stored.
 Set<JobKey> selectJobsInGroup(Connection conn, GroupMatcher<JobKey> matcher)
           Select all of the jobs contained in a given group.
 List<TriggerKey> selectMisfiredTriggers(Connection conn, long ts)
           Get the names of all of the triggers that have misfired.
 List<TriggerKey> selectMisfiredTriggersInGroupInState(Connection conn, String groupName, String state, long ts)
           Get the names of all of the triggers in the given group and state that have misfired.
 List<TriggerKey> selectMisfiredTriggersInState(Connection conn, String state, long ts)
           Get the names of all of the triggers in the given state that have misfired - according to the given timestamp.
 long selectNextFireTime(Connection conn)
          Deprecated. Does not account for misfires.
 int selectNumCalendars(Connection conn)
           Select the total number of calendars stored.
 int selectNumJobs(Connection conn)
           Select the total number of jobs stored.
 int selectNumTriggers(Connection conn)
           Select the total number of triggers stored.
 int selectNumTriggersForJob(Connection conn, JobKey jobKey)
           Select the number of triggers associated with a given job.
 Set<String> selectPausedTriggerGroups(Connection conn)
           
 List<SchedulerStateRecord> selectSchedulerStateRecords(Connection conn, String theInstanceId)
           A List of all current SchedulerStateRecords.
 OperableTrigger selectTrigger(Connection conn, TriggerKey triggerKey)
           Select a trigger.
 TriggerKey selectTriggerForFireTime(Connection conn, long fireTime)
           Select the trigger that will be fired at the given fire time.
 List<String> selectTriggerGroups(Connection conn)
           Select all of the trigger group names that are stored.
 List<String> selectTriggerGroups(Connection conn, GroupMatcher<TriggerKey> matcher)
           
 JobDataMap selectTriggerJobDataMap(Connection conn, String triggerName, String groupName)
           Select a trigger's JobDataMap.
 List<TriggerKey> selectTriggerKeysForJob(Connection conn, JobKey jobKey)
           Get the names of all of the triggers associated with the given job.
 List<OperableTrigger> selectTriggersForCalendar(Connection conn, String calName)
           Select the triggers for a calendar
 List<OperableTrigger> selectTriggersForJob(Connection conn, JobKey jobKey)
           Select the triggers for a job
 List<OperableTrigger> selectTriggersForRecoveringJobs(Connection conn)
           Select all of the triggers for jobs that are requesting recovery.
 Set<TriggerKey> selectTriggersInGroup(Connection conn, GroupMatcher<TriggerKey> matcher)
           Select all of the triggers contained in a given group.
 List<TriggerKey> selectTriggersInState(Connection conn, String state)
           Select all of the triggers in a given state.
 String selectTriggerState(Connection conn, TriggerKey triggerKey)
           Select a trigger' state value.
 TriggerStatus selectTriggerStatus(Connection conn, TriggerKey triggerKey)
           Select a trigger' status (state & next fire time).
 List<TriggerKey> selectTriggerToAcquire(Connection conn, long noLaterThan, long noEarlierThan)
          Deprecated. - This remained for compatibility reason. Use selectTriggerToAcquire(Connection, long, long, int) instead.
 List<TriggerKey> selectTriggerToAcquire(Connection conn, long noLaterThan, long noEarlierThan, int maxCount)
           Select the next trigger which will fire to fire between the two given timestamps in ascending order of fire time, and then descending by priority.
protected  ByteArrayOutputStream serializeJobData(JobDataMap data)
           Remove the transient data from and then create a serialized java.util.ByteArrayOutputStream version of a JobDataMap.
protected  ByteArrayOutputStream serializeObject(Object obj)
           Create a serialized java.util.ByteArrayOutputStream version of an Object.
protected  void setBoolean(PreparedStatement ps, int index, boolean val)
          Sets the designated parameter to the given Java boolean value.
protected  void setBytes(PreparedStatement ps, int index, ByteArrayOutputStream baos)
          Sets the designated parameter to the byte array of the given ByteArrayOutputStream.
protected  String toSqlEqualsClause(GroupMatcher<?> matcher)
           
protected  String toSqlLikeClause(GroupMatcher<?> matcher)
           
 boolean triggerExists(Connection conn, TriggerKey triggerKey)
           Check whether or not a trigger exists.
 int updateBlobTrigger(Connection conn, OperableTrigger trigger)
           Update the blob trigger data.
 int updateCalendar(Connection conn, String calendarName, Calendar calendar)
           Update a calendar.
 int updateFiredTrigger(Connection conn, OperableTrigger trigger, String state, JobDetail job)
           Update a fired trigger.
 int updateJobData(Connection conn, JobDetail job)
           Update the job data map for the given job.
 int updateJobDetail(Connection conn, JobDetail job)
           Update the job detail record.
 int updateSchedulerState(Connection conn, String theInstanceId, long checkInTime)
           Update a scheduler-instance state record.
 int updateTrigger(Connection conn, OperableTrigger trigger, String state, JobDetail jobDetail)
           Update the base trigger data.
 int updateTriggerGroupStateFromOtherState(Connection conn, GroupMatcher<TriggerKey> matcher, String newState, String oldState)
           Update all of the triggers of the given group to the given new state, if they are in the given old state.
 int updateTriggerGroupStateFromOtherStates(Connection conn, GroupMatcher<TriggerKey> matcher, String newState, String oldState1, String oldState2, String oldState3)
           Update all triggers in the given group to the given new state, if they are in one of the given old states.
 int updateTriggerState(Connection conn, TriggerKey triggerKey, String state)
           Update the state for a given trigger.
 int updateTriggerStateFromOtherState(Connection conn, TriggerKey triggerKey, String newState, String oldState)
           Update the given trigger to the given new state, if it is in the given old state.
 int updateTriggerStateFromOtherStates(Connection conn, TriggerKey triggerKey, String newState, String oldState1, String oldState2, String oldState3)
           Update the given trigger to the given new state, if it is one of the given old states.
 int updateTriggerStatesForJob(Connection conn, JobKey jobKey, String state)
           Update the states of all triggers associated with the given job.
 int updateTriggerStatesForJobFromOtherState(Connection conn, JobKey jobKey, String state, String oldState)
           Update the states of any triggers associated with the given job, that are the given current state.
 int updateTriggerStatesFromOtherStates(Connection conn, String newState, String oldState1, String oldState2)
           Insert the job detail record.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected org.slf4j.Logger logger

tablePrefix

protected String tablePrefix

instanceId

protected String instanceId

schedName

protected String schedName

useProperties

protected boolean useProperties

classLoadHelper

protected ClassLoadHelper classLoadHelper

triggerPersistenceDelegates

protected List<TriggerPersistenceDelegate> triggerPersistenceDelegates
Constructor Detail

StdJDBCDelegate

public StdJDBCDelegate()

Create new StdJDBCDelegate instance.

Method Detail

initialize

public void initialize(org.slf4j.Logger logger,
                       String tablePrefix,
                       String schedName,
                       String instanceId,
                       ClassLoadHelper classLoadHelper,
                       boolean useProperties,
                       String initString)
                throws NoSuchDelegateException
Specified by:
initialize in interface DriverDelegate
Parameters:
initString - of the format: settingName=settingValue|otherSettingName=otherSettingValue|...
Throws:
NoSuchDelegateException

addDefaultTriggerPersistenceDelegates

protected void addDefaultTriggerPersistenceDelegates()

canUseProperties

protected boolean canUseProperties()

addTriggerPersistenceDelegate

public void addTriggerPersistenceDelegate(TriggerPersistenceDelegate delegate)

findTriggerPersistenceDelegate

public TriggerPersistenceDelegate findTriggerPersistenceDelegate(OperableTrigger trigger)

findTriggerPersistenceDelegate

public TriggerPersistenceDelegate findTriggerPersistenceDelegate(String discriminator)

updateTriggerStatesFromOtherStates

public int updateTriggerStatesFromOtherStates(Connection conn,
                                              String newState,
                                              String oldState1,
                                              String oldState2)
                                       throws SQLException

Insert the job detail record.

Specified by:
updateTriggerStatesFromOtherStates in interface DriverDelegate
Parameters:
conn - the DB Connection
newState - the new state for the triggers
oldState1 - the first old state to update
oldState2 - the second old state to update
Returns:
number of rows updated
Throws:
SQLException

selectMisfiredTriggers

public List<TriggerKey> selectMisfiredTriggers(Connection conn,
                                               long ts)
                                        throws SQLException

Get the names of all of the triggers that have misfired.

Specified by:
selectMisfiredTriggers in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
an array of Key objects
Throws:
SQLException

selectTriggersInState

public List<TriggerKey> selectTriggersInState(Connection conn,
                                              String state)
                                       throws SQLException

Select all of the triggers in a given state.

Specified by:
selectTriggersInState in interface DriverDelegate
Parameters:
conn - the DB Connection
state - the state the triggers must be in
Returns:
an array of trigger Key s
Throws:
SQLException

selectMisfiredTriggersInState

public List<TriggerKey> selectMisfiredTriggersInState(Connection conn,
                                                      String state,
                                                      long ts)
                                               throws SQLException
Description copied from interface: DriverDelegate

Get the names of all of the triggers in the given state that have misfired - according to the given timestamp.

Specified by:
selectMisfiredTriggersInState in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
an array of Key objects
Throws:
SQLException

hasMisfiredTriggersInState

public boolean hasMisfiredTriggersInState(Connection conn,
                                          String state1,
                                          long ts,
                                          int count,
                                          List<TriggerKey> resultList)
                                   throws SQLException

Get the names of all of the triggers in the given state that have misfired - according to the given timestamp. No more than count will be returned.

Specified by:
hasMisfiredTriggersInState in interface DriverDelegate
Parameters:
conn - The DB Connection
count - The most misfired triggers to return, negative for all
resultList - Output parameter. A List of Key objects. Must not be null.
Returns:
Whether there are more misfired triggers left to find beyond the given count.
Throws:
SQLException

countMisfiredTriggersInState

public int countMisfiredTriggersInState(Connection conn,
                                        String state1,
                                        long ts)
                                 throws SQLException

Get the number of triggers in the given states that have misfired - according to the given timestamp.

Specified by:
countMisfiredTriggersInState in interface DriverDelegate
Parameters:
conn - the DB Connection
Throws:
SQLException

selectMisfiredTriggersInGroupInState

public List<TriggerKey> selectMisfiredTriggersInGroupInState(Connection conn,
                                                             String groupName,
                                                             String state,
                                                             long ts)
                                                      throws SQLException

Get the names of all of the triggers in the given group and state that have misfired.

Specified by:
selectMisfiredTriggersInGroupInState in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
an array of Key objects
Throws:
SQLException

selectTriggersForRecoveringJobs

public List<OperableTrigger> selectTriggersForRecoveringJobs(Connection conn)
                                                      throws SQLException,
                                                             IOException,
                                                             ClassNotFoundException

Select all of the triggers for jobs that are requesting recovery. The returned trigger objects will have unique "recoverXXX" trigger names and will be in the Scheduler.DEFAULT_RECOVERY_GROUP trigger group.

In order to preserve the ordering of the triggers, the fire time will be set from the COL_FIRED_TIME column in the TABLE_FIRED_TRIGGERS table. The caller is responsible for calling computeFirstFireTime on each returned trigger. It is also up to the caller to insert the returned triggers to ensure that they are fired.

Specified by:
selectTriggersForRecoveringJobs in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
an array of Trigger objects
Throws:
SQLException
IOException
ClassNotFoundException

deleteFiredTriggers

public int deleteFiredTriggers(Connection conn)
                        throws SQLException

Delete all fired triggers.

Specified by:
deleteFiredTriggers in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
the number of rows deleted
Throws:
SQLException

deleteFiredTriggers

public int deleteFiredTriggers(Connection conn,
                               String theInstanceId)
                        throws SQLException
Description copied from interface: DriverDelegate

Delete all fired triggers of the given instance.

Specified by:
deleteFiredTriggers in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
the number of rows deleted
Throws:
SQLException

clearData

public void clearData(Connection conn)
               throws SQLException
Clear (delete!) all scheduling data - all Jobs, Triggers Calendars.

Specified by:
clearData in interface DriverDelegate
Throws:
JobPersistenceException
SQLException

insertJobDetail

public int insertJobDetail(Connection conn,
                           JobDetail job)
                    throws IOException,
                           SQLException

Insert the job detail record.

Specified by:
insertJobDetail in interface DriverDelegate
Parameters:
conn - the DB Connection
job - the job to insert
Returns:
number of rows inserted
Throws:
IOException - if there were problems serializing the JobDataMap
SQLException

updateJobDetail

public int updateJobDetail(Connection conn,
                           JobDetail job)
                    throws IOException,
                           SQLException

Update the job detail record.

Specified by:
updateJobDetail in interface DriverDelegate
Parameters:
conn - the DB Connection
job - the job to update
Returns:
number of rows updated
Throws:
IOException - if there were problems serializing the JobDataMap
SQLException

selectTriggerKeysForJob

public List<TriggerKey> selectTriggerKeysForJob(Connection conn,
                                                JobKey jobKey)
                                         throws SQLException

Get the names of all of the triggers associated with the given job.

Specified by:
selectTriggerKeysForJob in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
an array of Key objects
Throws:
SQLException

deleteJobDetail

public int deleteJobDetail(Connection conn,
                           JobKey jobKey)
                    throws SQLException

Delete the job detail record for the given job.

Specified by:
deleteJobDetail in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
the number of rows deleted
Throws:
SQLException

isJobNonConcurrent

public boolean isJobNonConcurrent(Connection conn,
                                  JobKey jobKey)
                           throws SQLException

Check whether or not the given job is stateful.

Specified by:
isJobNonConcurrent in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
true if the job exists and is stateful, false otherwise
Throws:
SQLException

jobExists

public boolean jobExists(Connection conn,
                         JobKey jobKey)
                  throws SQLException

Check whether or not the given job exists.

Specified by:
jobExists in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
true if the job exists, false otherwise
Throws:
SQLException

updateJobData

public int updateJobData(Connection conn,
                         JobDetail job)
                  throws IOException,
                         SQLException

Update the job data map for the given job.

Specified by:
updateJobData in interface DriverDelegate
Parameters:
conn - the DB Connection
job - the job to update
Returns:
the number of rows updated
Throws:
IOException - if there were problems serializing the JobDataMap
SQLException

selectJobDetail

public JobDetail selectJobDetail(Connection conn,
                                 JobKey jobKey,
                                 ClassLoadHelper loadHelper)
                          throws ClassNotFoundException,
                                 IOException,
                                 SQLException

Select the JobDetail object for a given job name / group name.

Specified by:
selectJobDetail in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
the populated JobDetail object
Throws:
ClassNotFoundException - if a class found during deserialization cannot be found or if the job class could not be found
IOException - if deserialization causes an error
SQLException

selectNumJobs

public int selectNumJobs(Connection conn)
                  throws SQLException

Select the total number of jobs stored.

Specified by:
selectNumJobs in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
the total number of jobs stored
Throws:
SQLException

selectJobGroups

public List<String> selectJobGroups(Connection conn)
                             throws SQLException

Select all of the job group names that are stored.

Specified by:
selectJobGroups in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
an array of String group names
Throws:
SQLException

selectJobsInGroup

public Set<JobKey> selectJobsInGroup(Connection conn,
                                     GroupMatcher<JobKey> matcher)
                              throws SQLException

Select all of the jobs contained in a given group.

Specified by:
selectJobsInGroup in interface DriverDelegate
Parameters:
conn - the DB Connection
matcher - the groupMatcher to evaluate the jobs against
Returns:
an array of String job names
Throws:
SQLException

isMatcherEquals

protected boolean isMatcherEquals(GroupMatcher<?> matcher)

toSqlEqualsClause

protected String toSqlEqualsClause(GroupMatcher<?> matcher)

toSqlLikeClause

protected String toSqlLikeClause(GroupMatcher<?> matcher)

insertTrigger

public int insertTrigger(Connection conn,
                         OperableTrigger trigger,
                         String state,
                         JobDetail jobDetail)
                  throws SQLException,
                         IOException

Insert the base trigger data.

Specified by:
insertTrigger in interface DriverDelegate
Parameters:
conn - the DB Connection
trigger - the trigger to insert
state - the state that the trigger should be stored in
Returns:
the number of rows inserted
Throws:
SQLException
IOException

insertBlobTrigger

public int insertBlobTrigger(Connection conn,
                             OperableTrigger trigger)
                      throws SQLException,
                             IOException

Insert the blob trigger data.

Parameters:
conn - the DB Connection
trigger - the trigger to insert
Returns:
the number of rows inserted
Throws:
SQLException
IOException

updateTrigger

public int updateTrigger(Connection conn,
                         OperableTrigger trigger,
                         String state,
                         JobDetail jobDetail)
                  throws SQLException,
                         IOException

Update the base trigger data.

Specified by:
updateTrigger in interface DriverDelegate
Parameters:
conn - the DB Connection
trigger - the trigger to insert
state - the state that the trigger should be stored in
Returns:
the number of rows updated
Throws:
SQLException
IOException

updateBlobTrigger

public int updateBlobTrigger(Connection conn,
                             OperableTrigger trigger)
                      throws SQLException,
                             IOException

Update the blob trigger data.

Parameters:
conn - the DB Connection
trigger - the trigger to insert
Returns:
the number of rows updated
Throws:
SQLException
IOException

triggerExists

public boolean triggerExists(Connection conn,
                             TriggerKey triggerKey)
                      throws SQLException

Check whether or not a trigger exists.

Specified by:
triggerExists in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
true if the trigger exists, false otherwise
Throws:
SQLException

updateTriggerState

public int updateTriggerState(Connection conn,
                              TriggerKey triggerKey,
                              String state)
                       throws SQLException

Update the state for a given trigger.

Specified by:
updateTriggerState in interface DriverDelegate
Parameters:
conn - the DB Connection
state - the new state for the trigger
Returns:
the number of rows updated
Throws:
SQLException

updateTriggerStateFromOtherStates

public int updateTriggerStateFromOtherStates(Connection conn,
                                             TriggerKey triggerKey,
                                             String newState,
                                             String oldState1,
                                             String oldState2,
                                             String oldState3)
                                      throws SQLException

Update the given trigger to the given new state, if it is one of the given old states.

Specified by:
updateTriggerStateFromOtherStates in interface DriverDelegate
Parameters:
conn - the DB connection
newState - the new state for the trigger
oldState1 - one of the old state the trigger must be in
oldState2 - one of the old state the trigger must be in
oldState3 - one of the old state the trigger must be in
Returns:
int the number of rows updated
Throws:
SQLException

updateTriggerGroupStateFromOtherStates

public int updateTriggerGroupStateFromOtherStates(Connection conn,
                                                  GroupMatcher<TriggerKey> matcher,
                                                  String newState,
                                                  String oldState1,
                                                  String oldState2,
                                                  String oldState3)
                                           throws SQLException

Update all triggers in the given group to the given new state, if they are in one of the given old states.

Specified by:
updateTriggerGroupStateFromOtherStates in interface DriverDelegate
Parameters:
conn - the DB connection
matcher - the groupMatcher to evaluate the triggers against
newState - the new state for the trigger
oldState1 - one of the old state the trigger must be in
oldState2 - one of the old state the trigger must be in
oldState3 - one of the old state the trigger must be in
Returns:
int the number of rows updated
Throws:
SQLException

updateTriggerStateFromOtherState

public int updateTriggerStateFromOtherState(Connection conn,
                                            TriggerKey triggerKey,
                                            String newState,
                                            String oldState)
                                     throws SQLException

Update the given trigger to the given new state, if it is in the given old state.

Specified by:
updateTriggerStateFromOtherState in interface DriverDelegate
Parameters:
conn - the DB connection
newState - the new state for the trigger
oldState - the old state the trigger must be in
Returns:
int the number of rows updated
Throws:
SQLException

updateTriggerGroupStateFromOtherState

public int updateTriggerGroupStateFromOtherState(Connection conn,
                                                 GroupMatcher<TriggerKey> matcher,
                                                 String newState,
                                                 String oldState)
                                          throws SQLException

Update all of the triggers of the given group to the given new state, if they are in the given old state.

Specified by:
updateTriggerGroupStateFromOtherState in interface DriverDelegate
Parameters:
conn - the DB connection
matcher - the groupMatcher to evaluate the triggers against
newState - the new state for the trigger group
oldState - the old state the triggers must be in
Returns:
int the number of rows updated
Throws:
SQLException

updateTriggerStatesForJob

public int updateTriggerStatesForJob(Connection conn,
                                     JobKey jobKey,
                                     String state)
                              throws SQLException

Update the states of all triggers associated with the given job.

Specified by:
updateTriggerStatesForJob in interface DriverDelegate
Parameters:
conn - the DB Connection
state - the new state for the triggers
Returns:
the number of rows updated
Throws:
SQLException

updateTriggerStatesForJobFromOtherState

public int updateTriggerStatesForJobFromOtherState(Connection conn,
                                                   JobKey jobKey,
                                                   String state,
                                                   String oldState)
                                            throws SQLException
Description copied from interface: DriverDelegate

Update the states of any triggers associated with the given job, that are the given current state.

Specified by:
updateTriggerStatesForJobFromOtherState in interface DriverDelegate
Parameters:
conn - the DB Connection
state - the new state for the triggers
oldState - the old state of the triggers
Returns:
the number of rows updated
Throws:
SQLException

deleteBlobTrigger

public int deleteBlobTrigger(Connection conn,
                             TriggerKey triggerKey)
                      throws SQLException

Delete the cron trigger data for a trigger.

Parameters:
conn - the DB Connection
Returns:
the number of rows deleted
Throws:
SQLException

deleteTrigger

public int deleteTrigger(Connection conn,
                         TriggerKey triggerKey)
                  throws SQLException

Delete the base trigger data for a trigger.

Specified by:
deleteTrigger in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
the number of rows deleted
Throws:
SQLException

deleteTriggerExtension

protected void deleteTriggerExtension(Connection conn,
                                      TriggerKey triggerKey)
                               throws SQLException
Throws:
SQLException

selectNumTriggersForJob

public int selectNumTriggersForJob(Connection conn,
                                   JobKey jobKey)
                            throws SQLException

Select the number of triggers associated with a given job.

Specified by:
selectNumTriggersForJob in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
the number of triggers for the given job
Throws:
SQLException

selectJobForTrigger

public JobDetail selectJobForTrigger(Connection conn,
                                     ClassLoadHelper loadHelper,
                                     TriggerKey triggerKey)
                              throws ClassNotFoundException,
                                     SQLException

Select the job to which the trigger is associated.

Specified by:
selectJobForTrigger in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
the JobDetail object associated with the given trigger
Throws:
SQLException
ClassNotFoundException

selectJobForTrigger

public JobDetail selectJobForTrigger(Connection conn,
                                     ClassLoadHelper loadHelper,
                                     TriggerKey triggerKey,
                                     boolean loadJobClass)
                              throws ClassNotFoundException,
                                     SQLException

Select the job to which the trigger is associated. Allow option to load actual job class or not. When case of remove, we do not need to load the class, which in many cases, it's no longer exists.

Specified by:
selectJobForTrigger in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
the JobDetail object associated with the given trigger
Throws:
SQLException
ClassNotFoundException

selectTriggersForJob

public List<OperableTrigger> selectTriggersForJob(Connection conn,
                                                  JobKey jobKey)
                                           throws SQLException,
                                                  ClassNotFoundException,
                                                  IOException,
                                                  JobPersistenceException

Select the triggers for a job

Specified by:
selectTriggersForJob in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
an array of (@link org.quartz.Trigger) objects associated with a given job.
Throws:
SQLException
JobPersistenceException
ClassNotFoundException
IOException

selectTriggersForCalendar

public List<OperableTrigger> selectTriggersForCalendar(Connection conn,
                                                       String calName)
                                                throws SQLException,
                                                       ClassNotFoundException,
                                                       IOException,
                                                       JobPersistenceException
Description copied from interface: DriverDelegate

Select the triggers for a calendar

Specified by:
selectTriggersForCalendar in interface DriverDelegate
Parameters:
conn - the DB Connection
calName - the name of the calendar
Returns:
an array of (@link org.quartz.Trigger) objects associated with the given calendar.
Throws:
SQLException
JobPersistenceException
ClassNotFoundException
IOException

selectTrigger

public OperableTrigger selectTrigger(Connection conn,
                                     TriggerKey triggerKey)
                              throws SQLException,
                                     ClassNotFoundException,
                                     IOException,
                                     JobPersistenceException

Select a trigger.

Specified by:
selectTrigger in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
the Trigger object
Throws:
JobPersistenceException
SQLException
ClassNotFoundException
IOException

selectTriggerJobDataMap

public JobDataMap selectTriggerJobDataMap(Connection conn,
                                          String triggerName,
                                          String groupName)
                                   throws SQLException,
                                          ClassNotFoundException,
                                          IOException

Select a trigger's JobDataMap.

Specified by:
selectTriggerJobDataMap in interface DriverDelegate
Parameters:
conn - the DB Connection
triggerName - the name of the trigger
groupName - the group containing the trigger
Returns:
the JobDataMap of the Trigger, never null, but possibly empty.
Throws:
SQLException
ClassNotFoundException
IOException

selectTriggerState

public String selectTriggerState(Connection conn,
                                 TriggerKey triggerKey)
                          throws SQLException

Select a trigger' state value.

Specified by:
selectTriggerState in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
the Trigger object
Throws:
SQLException

selectTriggerStatus

public TriggerStatus selectTriggerStatus(Connection conn,
                                         TriggerKey triggerKey)
                                  throws SQLException

Select a trigger' status (state & next fire time).

Specified by:
selectTriggerStatus in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
a TriggerStatus object, or null
Throws:
SQLException

selectNumTriggers

public int selectNumTriggers(Connection conn)
                      throws SQLException

Select the total number of triggers stored.

Specified by:
selectNumTriggers in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
the total number of triggers stored
Throws:
SQLException

selectTriggerGroups

public List<String> selectTriggerGroups(Connection conn)
                                 throws SQLException

Select all of the trigger group names that are stored.

Specified by:
selectTriggerGroups in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
an array of String group names
Throws:
SQLException

selectTriggerGroups

public List<String> selectTriggerGroups(Connection conn,
                                        GroupMatcher<TriggerKey> matcher)
                                 throws SQLException
Specified by:
selectTriggerGroups in interface DriverDelegate
Throws:
SQLException

selectTriggersInGroup

public Set<TriggerKey> selectTriggersInGroup(Connection conn,
                                             GroupMatcher<TriggerKey> matcher)
                                      throws SQLException

Select all of the triggers contained in a given group.

Specified by:
selectTriggersInGroup in interface DriverDelegate
Parameters:
conn - the DB Connection
matcher - to evaluate against known triggers
Returns:
a Set of TriggerKeys
Throws:
SQLException

insertPausedTriggerGroup

public int insertPausedTriggerGroup(Connection conn,
                                    String groupName)
                             throws SQLException
Specified by:
insertPausedTriggerGroup in interface DriverDelegate
Throws:
SQLException

deletePausedTriggerGroup

public int deletePausedTriggerGroup(Connection conn,
                                    String groupName)
                             throws SQLException
Specified by:
deletePausedTriggerGroup in interface DriverDelegate
Throws:
SQLException

deletePausedTriggerGroup

public int deletePausedTriggerGroup(Connection conn,
                                    GroupMatcher<TriggerKey> matcher)
                             throws SQLException
Specified by:
deletePausedTriggerGroup in interface DriverDelegate
Throws:
SQLException

deleteAllPausedTriggerGroups

public int deleteAllPausedTriggerGroups(Connection conn)
                                 throws SQLException
Specified by:
deleteAllPausedTriggerGroups in interface DriverDelegate
Throws:
SQLException

isTriggerGroupPaused

public boolean isTriggerGroupPaused(Connection conn,
                                    String groupName)
                             throws SQLException
Specified by:
isTriggerGroupPaused in interface DriverDelegate
Throws:
SQLException

isExistingTriggerGroup

public boolean isExistingTriggerGroup(Connection conn,
                                      String groupName)
                               throws SQLException
Specified by:
isExistingTriggerGroup in interface DriverDelegate
Throws:
SQLException

insertCalendar

public int insertCalendar(Connection conn,
                          String calendarName,
                          Calendar calendar)
                   throws IOException,
                          SQLException

Insert a new calendar.

Specified by:
insertCalendar in interface DriverDelegate
Parameters:
conn - the DB Connection
calendarName - the name for the new calendar
calendar - the calendar
Returns:
the number of rows inserted
Throws:
IOException - if there were problems serializing the calendar
SQLException

updateCalendar

public int updateCalendar(Connection conn,
                          String calendarName,
                          Calendar calendar)
                   throws IOException,
                          SQLException

Update a calendar.

Specified by:
updateCalendar in interface DriverDelegate
Parameters:
conn - the DB Connection
calendarName - the name for the new calendar
calendar - the calendar
Returns:
the number of rows updated
Throws:
IOException - if there were problems serializing the calendar
SQLException

calendarExists

public boolean calendarExists(Connection conn,
                              String calendarName)
                       throws SQLException

Check whether or not a calendar exists.

Specified by:
calendarExists in interface DriverDelegate
Parameters:
conn - the DB Connection
calendarName - the name of the calendar
Returns:
true if the trigger exists, false otherwise
Throws:
SQLException

selectCalendar

public Calendar selectCalendar(Connection conn,
                               String calendarName)
                        throws ClassNotFoundException,
                               IOException,
                               SQLException

Select a calendar.

Specified by:
selectCalendar in interface DriverDelegate
Parameters:
conn - the DB Connection
calendarName - the name of the calendar
Returns:
the Calendar
Throws:
ClassNotFoundException - if a class found during deserialization cannot be found be found
IOException - if there were problems deserializing the calendar
SQLException

calendarIsReferenced

public boolean calendarIsReferenced(Connection conn,
                                    String calendarName)
                             throws SQLException

Check whether or not a calendar is referenced by any triggers.

Specified by:
calendarIsReferenced in interface DriverDelegate
Parameters:
conn - the DB Connection
calendarName - the name of the calendar
Returns:
true if any triggers reference the calendar, false otherwise
Throws:
SQLException

deleteCalendar

public int deleteCalendar(Connection conn,
                          String calendarName)
                   throws SQLException

Delete a calendar.

Specified by:
deleteCalendar in interface DriverDelegate
Parameters:
conn - the DB Connection
calendarName - the name of the trigger
Returns:
the number of rows deleted
Throws:
SQLException

selectNumCalendars

public int selectNumCalendars(Connection conn)
                       throws SQLException

Select the total number of calendars stored.

Specified by:
selectNumCalendars in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
the total number of calendars stored
Throws:
SQLException

selectCalendars

public List<String> selectCalendars(Connection conn)
                             throws SQLException

Select all of the stored calendars.

Specified by:
selectCalendars in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
an array of String calendar names
Throws:
SQLException

selectNextFireTime

public long selectNextFireTime(Connection conn)
                        throws SQLException
Deprecated. Does not account for misfires.

Select the next time that a trigger will be fired.

Specified by:
selectNextFireTime in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
the next fire time, or 0 if no trigger will be fired
Throws:
SQLException

selectTriggerForFireTime

public TriggerKey selectTriggerForFireTime(Connection conn,
                                           long fireTime)
                                    throws SQLException

Select the trigger that will be fired at the given fire time.

Specified by:
selectTriggerForFireTime in interface DriverDelegate
Parameters:
conn - the DB Connection
fireTime - the time that the trigger will be fired
Returns:
a Key representing the trigger that will be fired at the given fire time, or null if no trigger will be fired at that time
Throws:
SQLException

selectTriggerToAcquire

public List<TriggerKey> selectTriggerToAcquire(Connection conn,
                                               long noLaterThan,
                                               long noEarlierThan)
                                        throws SQLException
Deprecated. - This remained for compatibility reason. Use selectTriggerToAcquire(Connection, long, long, int) instead.

Select the next trigger which will fire to fire between the two given timestamps in ascending order of fire time, and then descending by priority.

Specified by:
selectTriggerToAcquire in interface DriverDelegate
Parameters:
conn - the DB Connection
noLaterThan - highest value of getNextFireTime() of the triggers (exclusive)
noEarlierThan - highest value of getNextFireTime() of the triggers (inclusive)
Returns:
A (never null, possibly empty) list of the identifiers (Key objects) of the next triggers to be fired.
Throws:
SQLException

selectTriggerToAcquire

public List<TriggerKey> selectTriggerToAcquire(Connection conn,
                                               long noLaterThan,
                                               long noEarlierThan,
                                               int maxCount)
                                        throws SQLException

Select the next trigger which will fire to fire between the two given timestamps in ascending order of fire time, and then descending by priority.

Specified by:
selectTriggerToAcquire in interface DriverDelegate
Parameters:
conn - the DB Connection
noLaterThan - highest value of getNextFireTime() of the triggers (exclusive)
noEarlierThan - highest value of getNextFireTime() of the triggers (inclusive)
maxCount - maximum number of trigger keys allow to acquired in the returning list.
Returns:
A (never null, possibly empty) list of the identifiers (Key objects) of the next triggers to be fired.
Throws:
SQLException

insertFiredTrigger

public int insertFiredTrigger(Connection conn,
                              OperableTrigger trigger,
                              String state,
                              JobDetail job)
                       throws SQLException

Insert a fired trigger.

Specified by:
insertFiredTrigger in interface DriverDelegate
Parameters:
conn - the DB Connection
trigger - the trigger
state - the state that the trigger should be stored in
Returns:
the number of rows inserted
Throws:
SQLException

updateFiredTrigger

public int updateFiredTrigger(Connection conn,
                              OperableTrigger trigger,
                              String state,
                              JobDetail job)
                       throws SQLException

Update a fired trigger.

Specified by:
updateFiredTrigger in interface DriverDelegate
Parameters:
conn - the DB Connection
trigger - the trigger
state - the state that the trigger should be stored in
Returns:
the number of rows inserted
Throws:
SQLException

selectFiredTriggerRecords

public List<FiredTriggerRecord> selectFiredTriggerRecords(Connection conn,
                                                          String triggerName,
                                                          String groupName)
                                                   throws SQLException

Select the states of all fired-trigger records for a given trigger, or trigger group if trigger name is null.

Specified by:
selectFiredTriggerRecords in interface DriverDelegate
Returns:
a List of FiredTriggerRecord objects.
Throws:
SQLException

selectFiredTriggerRecordsByJob

public List<FiredTriggerRecord> selectFiredTriggerRecordsByJob(Connection conn,
                                                               String jobName,
                                                               String groupName)
                                                        throws SQLException

Select the states of all fired-trigger records for a given job, or job group if job name is null.

Specified by:
selectFiredTriggerRecordsByJob in interface DriverDelegate
Returns:
a List of FiredTriggerRecord objects.
Throws:
SQLException

selectInstancesFiredTriggerRecords

public List<FiredTriggerRecord> selectInstancesFiredTriggerRecords(Connection conn,
                                                                   String instanceName)
                                                            throws SQLException
Description copied from interface: DriverDelegate

Select the states of all fired-trigger records for a given scheduler instance.

Specified by:
selectInstancesFiredTriggerRecords in interface DriverDelegate
Returns:
a List of FiredTriggerRecord objects.
Throws:
SQLException

selectFiredTriggerInstanceNames

public Set<String> selectFiredTriggerInstanceNames(Connection conn)
                                            throws SQLException

Select the distinct instance names of all fired-trigger records.

This is useful when trying to identify orphaned fired triggers (a fired trigger without a scheduler state record.)

Specified by:
selectFiredTriggerInstanceNames in interface DriverDelegate
Returns:
a Set of String objects.
Throws:
SQLException

deleteFiredTrigger

public int deleteFiredTrigger(Connection conn,
                              String entryId)
                       throws SQLException

Delete a fired trigger.

Specified by:
deleteFiredTrigger in interface DriverDelegate
Parameters:
conn - the DB Connection
entryId - the fired trigger entry to delete
Returns:
the number of rows deleted
Throws:
SQLException

selectJobExecutionCount

public int selectJobExecutionCount(Connection conn,
                                   JobKey jobKey)
                            throws SQLException
Description copied from interface: DriverDelegate

Get the number instances of the identified job currently executing.

Specified by:
selectJobExecutionCount in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
the number instances of the identified job currently executing.
Throws:
SQLException

insertSchedulerState

public int insertSchedulerState(Connection conn,
                                String theInstanceId,
                                long checkInTime,
                                long interval)
                         throws SQLException
Description copied from interface: DriverDelegate

Insert a scheduler-instance state record.

Specified by:
insertSchedulerState in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
the number of inserted rows.
Throws:
SQLException

deleteSchedulerState

public int deleteSchedulerState(Connection conn,
                                String theInstanceId)
                         throws SQLException
Description copied from interface: DriverDelegate

Delete a scheduler-instance state record.

Specified by:
deleteSchedulerState in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
the number of deleted rows.
Throws:
SQLException

updateSchedulerState

public int updateSchedulerState(Connection conn,
                                String theInstanceId,
                                long checkInTime)
                         throws SQLException
Description copied from interface: DriverDelegate

Update a scheduler-instance state record.

Specified by:
updateSchedulerState in interface DriverDelegate
Parameters:
conn - the DB Connection
Returns:
the number of updated rows.
Throws:
SQLException

selectSchedulerStateRecords

public List<SchedulerStateRecord> selectSchedulerStateRecords(Connection conn,
                                                              String theInstanceId)
                                                       throws SQLException
Description copied from interface: DriverDelegate

A List of all current SchedulerStateRecords.

If instanceId is not null, then only the record for the identified instance will be returned.

Specified by:
selectSchedulerStateRecords in interface DriverDelegate
Parameters:
conn - the DB Connection
Throws:
SQLException

rtp

protected final String rtp(String query)

Replace the table prefix in a query by replacing any occurrences of "{0}" with the table prefix.

Parameters:
query - the unsubstitued query
Returns:
the query, with proper table prefix substituted

getSchedulerNameLiteral

protected String getSchedulerNameLiteral()

serializeObject

protected ByteArrayOutputStream serializeObject(Object obj)
                                         throws IOException

Create a serialized java.util.ByteArrayOutputStream version of an Object.

Parameters:
obj - the object to serialize
Returns:
the serialized ByteArrayOutputStream
Throws:
IOException - if serialization causes an error

serializeJobData

protected ByteArrayOutputStream serializeJobData(JobDataMap data)
                                          throws IOException

Remove the transient data from and then create a serialized java.util.ByteArrayOutputStream version of a JobDataMap.

Parameters:
data - the JobDataMap to serialize
Returns:
the serialized ByteArrayOutputStream
Throws:
IOException - if serialization causes an error

getKeyOfNonSerializableValue

protected Object getKeyOfNonSerializableValue(Map<?,?> data)
Find the key of the first non-serializable value in the given Map.

Returns:
The key of the first non-serializable value in the given Map or null if all values are serializable.

convertFromProperty

protected Map<?,?> convertFromProperty(Properties properties)
                                throws IOException
convert the JobDataMap into a list of properties

Throws:
IOException

convertToProperty

protected Properties convertToProperty(Map<?,?> data)
                                throws IOException
convert the JobDataMap into a list of properties

Throws:
IOException

getObjectFromBlob

protected Object getObjectFromBlob(ResultSet rs,
                                   String colName)
                            throws ClassNotFoundException,
                                   IOException,
                                   SQLException

This method should be overridden by any delegate subclasses that need special handling for BLOBs. The default implementation uses standard JDBC java.sql.Blob operations.

Parameters:
rs - the result set, already queued to the correct row
colName - the column name for the BLOB
Returns:
the deserialized Object from the ResultSet BLOB
Throws:
ClassNotFoundException - if a class found during deserialization cannot be found
IOException - if deserialization causes an error
SQLException

getJobDataFromBlob

protected Object getJobDataFromBlob(ResultSet rs,
                                    String colName)
                             throws ClassNotFoundException,
                                    IOException,
                                    SQLException

This method should be overridden by any delegate subclasses that need special handling for BLOBs for job details. The default implementation uses standard JDBC java.sql.Blob operations.

Parameters:
rs - the result set, already queued to the correct row
colName - the column name for the BLOB
Returns:
the deserialized Object from the ResultSet BLOB
Throws:
ClassNotFoundException - if a class found during deserialization cannot be found
IOException - if deserialization causes an error
SQLException

selectPausedTriggerGroups

public Set<String> selectPausedTriggerGroups(Connection conn)
                                      throws SQLException
Specified by:
selectPausedTriggerGroups in interface DriverDelegate
Throws:
SQLException
See Also:
DriverDelegate.selectPausedTriggerGroups(java.sql.Connection)

closeResultSet

protected static void closeResultSet(ResultSet rs)
Cleanup helper method that closes the given ResultSet while ignoring any errors.


closeStatement

protected static void closeStatement(Statement statement)
Cleanup helper method that closes the given Statement while ignoring any errors.


setBoolean

protected void setBoolean(PreparedStatement ps,
                          int index,
                          boolean val)
                   throws SQLException
Sets the designated parameter to the given Java boolean value. This just wraps PreparedStatement.setBoolean(int, boolean) by default, but it can be overloaded by subclass delegates for databases that don't explicitly support the boolean type.

Throws:
SQLException

getBoolean

protected boolean getBoolean(ResultSet rs,
                             String columnName)
                      throws SQLException
Retrieves the value of the designated column in the current row as a boolean. This just wraps ResultSet.getBoolean(java.lang.String) by default, but it can be overloaded by subclass delegates for databases that don't explicitly support the boolean type.

Throws:
SQLException

getBoolean

protected boolean getBoolean(ResultSet rs,
                             int columnIndex)
                      throws SQLException
Retrieves the value of the designated column index in the current row as a boolean. This just wraps ResultSet.getBoolean(java.lang.String) by default, but it can be overloaded by subclass delegates for databases that don't explicitly support the boolean type.

Throws:
SQLException

setBytes

protected void setBytes(PreparedStatement ps,
                        int index,
                        ByteArrayOutputStream baos)
                 throws SQLException
Sets the designated parameter to the byte array of the given ByteArrayOutputStream. Will set parameter value to null if the ByteArrayOutputStream is null. This just wraps PreparedStatement.setBytes(int, byte[]) by default, but it can be overloaded by subclass delegates for databases that don't explicitly support storing bytes in this way.

Throws:
SQLException


Copyright 2001-2015, Terracotta, Inc.