Search in sources :

Example 21 with JobPersistenceException

use of org.quartz.JobPersistenceException in project weicoder by wdcode.

the class JobStoreSupport method releaseAcquiredTrigger.

protected void releaseAcquiredTrigger(Connection conn, OperableTrigger trigger) throws JobPersistenceException {
    try {
        getDelegate().updateTriggerStateFromOtherState(conn, trigger.getKey(), STATE_WAITING, STATE_ACQUIRED);
        getDelegate().updateTriggerStateFromOtherState(conn, trigger.getKey(), STATE_WAITING, STATE_BLOCKED);
        getDelegate().deleteFiredTrigger(conn, trigger.getFireInstanceId());
    } catch (SQLException e) {
        throw new JobPersistenceException("Couldn't release acquired trigger: " + e.getMessage(), e);
    }
}
Also used : SQLException(java.sql.SQLException) JobPersistenceException(org.quartz.JobPersistenceException)

Example 22 with JobPersistenceException

use of org.quartz.JobPersistenceException in project weicoder by wdcode.

the class JobStoreSupport method getConnection.

protected Connection getConnection() throws JobPersistenceException {
    Connection conn;
    try {
        conn = DBConnectionManager.getInstance().getConnection(getDataSource());
    } catch (SQLException sqle) {
        throw new JobPersistenceException("Failed to obtain DB connection from data source '" + getDataSource() + "': " + sqle.toString(), sqle);
    } catch (Throwable e) {
        throw new JobPersistenceException("Failed to obtain DB connection from data source '" + getDataSource() + "': " + e.toString(), e);
    }
    if (conn == null) {
        throw new JobPersistenceException("Could not get connection from DataSource '" + getDataSource() + "'");
    }
    // Protect connection attributes we might change.
    conn = getAttributeRestoringConnection(conn);
    // Set any connection connection attributes we are to override.
    try {
        if (!isDontSetAutoCommitFalse()) {
            conn.setAutoCommit(false);
        }
        if (isTxIsolationLevelSerializable()) {
            conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
        }
    } catch (SQLException sqle) {
        getLog().warn("Failed to override connection auto commit/transaction isolation.", sqle);
    } catch (Throwable e) {
        try {
            conn.close();
        } catch (Throwable ignored) {
        }
        throw new JobPersistenceException("Failure setting up connection.", e);
    }
    return conn;
}
Also used : SQLException(java.sql.SQLException) JobPersistenceException(org.quartz.JobPersistenceException) Connection(java.sql.Connection)

Example 23 with JobPersistenceException

use of org.quartz.JobPersistenceException in project weicoder by wdcode.

the class Util method setBeanProps.

public static void setBeanProps(Object obj, String[] propNames, Object[] propValues) throws JobPersistenceException {
    if (propNames == null || propNames.length == 0)
        return;
    if (propNames.length != propValues.length)
        throw new IllegalArgumentException("propNames[].lenght != propValues[].length");
    String name = null;
    try {
        BeanInfo bi = Introspector.getBeanInfo(obj.getClass());
        PropertyDescriptor[] propDescs = bi.getPropertyDescriptors();
        for (int i = 0; i < propNames.length; i++) {
            name = propNames[i];
            String c = name.substring(0, 1).toUpperCase(Locale.US);
            String methName = "set" + c + name.substring(1);
            java.lang.reflect.Method setMeth = getSetMethod(methName, propDescs);
            if (setMeth == null) {
                throw new NoSuchMethodException("No setter for property '" + name + "'");
            }
            Class<?>[] params = setMeth.getParameterTypes();
            if (params.length != 1) {
                throw new NoSuchMethodException("No 1-argument setter for property '" + name + "'");
            }
            setMeth.invoke(obj, new Object[] { propValues[i] });
        }
    } catch (Exception e) {
        throw new JobPersistenceException("Unable to set property named: " + name + " of object of type: " + obj.getClass().getCanonicalName(), e);
    }
}
Also used : PropertyDescriptor(java.beans.PropertyDescriptor) JobPersistenceException(org.quartz.JobPersistenceException) BeanInfo(java.beans.BeanInfo) SQLException(java.sql.SQLException) JobPersistenceException(org.quartz.JobPersistenceException)

Aggregations

JobPersistenceException (org.quartz.JobPersistenceException)23 SQLException (java.sql.SQLException)17 IOException (java.io.IOException)6 Date (java.util.Date)6 ObjectAlreadyExistsException (org.quartz.ObjectAlreadyExistsException)6 SchedulerException (org.quartz.SchedulerException)6 OperableTrigger (org.quartz.spi.OperableTrigger)6 JobDetail (org.quartz.JobDetail)5 Connection (java.sql.Connection)4 HashSet (java.util.HashSet)4 SchedulerConfigException (org.quartz.SchedulerConfigException)4 TriggerKey (org.quartz.TriggerKey)4 JobDataMap (org.quartz.JobDataMap)3 ArrayList (java.util.ArrayList)2 JobKey (org.quartz.JobKey)2 TriggerFiredBundle (org.quartz.spi.TriggerFiredBundle)2 BeanInfo (java.beans.BeanInfo)1 PropertyDescriptor (java.beans.PropertyDescriptor)1 NotSerializableException (java.io.NotSerializableException)1 PreparedStatement (java.sql.PreparedStatement)1