⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pointbasedelegate.java

📁 Quartz is a full-featured, open source job scheduling system that can be integrated with, or used al
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());                        PreparedStatement ps = null;        int insertResult = 0;        try {            ps = conn.prepareStatement(rtp(UPDATE_TRIGGER));                            ps.setString(1, trigger.getJobName());            ps.setString(2, trigger.getJobGroup());            setBoolean(ps, 3, trigger.isVolatile());            ps.setString(4, trigger.getDescription());            long nextFireTime = -1;            if (trigger.getNextFireTime() != null) {                nextFireTime = trigger.getNextFireTime().getTime();            }            ps.setBigDecimal(5, new BigDecimal(String.valueOf(nextFireTime)));            long prevFireTime = -1;            if (trigger.getPreviousFireTime() != null) {                prevFireTime = trigger.getPreviousFireTime().getTime();            }            ps.setBigDecimal(6, new BigDecimal(String.valueOf(prevFireTime)));            ps.setString(7, state);            if (trigger.getClass() == SimpleTrigger.class) {                //                updateSimpleTrigger(conn, (SimpleTrigger)trigger);                ps.setString(8, TTYPE_SIMPLE);            } else if (trigger.getClass() == CronTrigger.class) {                //                updateCronTrigger(conn, (CronTrigger)trigger);                ps.setString(8, TTYPE_CRON);            } else {                //                updateBlobTrigger(conn, trigger);                ps.setString(8, TTYPE_BLOB);            }            ps.setBigDecimal(9, new BigDecimal(String.valueOf(trigger                    .getStartTime().getTime())));            long endTime = 0;            if (trigger.getEndTime() != null) {                endTime = trigger.getEndTime().getTime();            }            ps.setBigDecimal(10, new BigDecimal(String.valueOf(endTime)));            ps.setString(11, trigger.getCalendarName());            ps.setInt(12, trigger.getMisfireInstruction());                        ps.setInt(13, trigger.getPriority());            ps.setBinaryStream(14, bais, len);            ps.setString(15, trigger.getName());            ps.setString(16, trigger.getGroup());            insertResult = ps.executeUpdate();        } finally {            closeStatement(ps);        }        if (insertResult > 0) {            deleteTriggerListeners(conn, trigger.getName(), trigger.getGroup());            String[] trigListeners = trigger.getTriggerListenerNames();            for (int i = 0; trigListeners != null && i < trigListeners.length; i++) {                insertTriggerListener(conn, trigger, trigListeners[i]);            }        }        return insertResult;    }    /**     * <p>     * Update the job data map for the given job.     * </p>     *      * @param conn     *          the DB Connection     * @param job     *          the job to update     * @return the number of rows updated     */    public int updateJobData(Connection conn, JobDetail job)        throws IOException, SQLException {        //log.debug( "Updating Job Data for Job " + job );        ByteArrayOutputStream baos = serializeJobData(job.getJobDataMap());        int len = baos.toByteArray().length;        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());        PreparedStatement ps = null;        try {            ps = conn.prepareStatement(rtp(UPDATE_JOB_DATA));            ps.setBinaryStream(1, bais, len);            ps.setString(2, job.getName());            ps.setString(3, job.getGroup());            return ps.executeUpdate();        } finally {            closeStatement(ps);        }    }    //---------------------------------------------------------------------------    // triggers    //---------------------------------------------------------------------------    //---------------------------------------------------------------------------    // calendars    //---------------------------------------------------------------------------    /**     * <p>     * Insert a new calendar.     * </p>     *      * @param conn     *          the DB Connection     * @param calendarName     *          the name for the new calendar     * @param calendar     *          the calendar     * @return the number of rows inserted     * @throws IOException     *           if there were problems serializing the calendar     */    public int insertCalendar(Connection conn, String calendarName,            Calendar calendar) throws IOException, SQLException {        //log.debug( "Inserting Calendar " + calendarName + " : " + calendar        // );        ByteArrayOutputStream baos = serializeObject(calendar);        byte buf[] = baos.toByteArray();        ByteArrayInputStream bais = new ByteArrayInputStream(buf);        PreparedStatement ps = null;        try {            ps = conn.prepareStatement(rtp(INSERT_CALENDAR));            ps.setString(1, calendarName);            ps.setBinaryStream(2, bais, buf.length);            return ps.executeUpdate();        } finally {            closeStatement(ps);        }    }    /**     * <p>     * Update a calendar.     * </p>     *      * @param conn     *          the DB Connection     * @param calendarName     *          the name for the new calendar     * @param calendar     *          the calendar     * @return the number of rows updated     * @throws IOException     *           if there were problems serializing the calendar     */    public int updateCalendar(Connection conn, String calendarName,            Calendar calendar) throws IOException, SQLException {        //log.debug( "Updating calendar " + calendarName + " : " + calendar );        ByteArrayOutputStream baos = serializeObject(calendar);        byte buf[] = baos.toByteArray();        ByteArrayInputStream bais = new ByteArrayInputStream(buf);        PreparedStatement ps = null;        try {            ps = conn.prepareStatement(rtp(UPDATE_CALENDAR));            ps.setBinaryStream(1, bais, buf.length);            ps.setString(2, calendarName);            return ps.executeUpdate();        } finally {            closeStatement(ps);        }    }    //---------------------------------------------------------------------------    // protected methods that can be overridden by subclasses    //---------------------------------------------------------------------------    /**     * <p>     * This method should be overridden by any delegate subclasses that need     * special handling for BLOBs. The default implementation uses standard     * JDBC <code>java.sql.Blob</code> operations.     * </p>     *      * @param rs     *          the result set, already queued to the correct row     * @param colName     *          the column name for the BLOB     * @return the deserialized Object from the ResultSet BLOB     * @throws ClassNotFoundException     *           if a class found during deserialization cannot be found     * @throws IOException     *           if deserialization causes an error     */    protected Object getObjectFromBlob(ResultSet rs, String colName)        throws ClassNotFoundException, IOException, SQLException {        //log.debug( "Getting blob from column: " + colName );        Object obj = null;        byte binaryData[] = rs.getBytes(colName);        InputStream binaryInput = new ByteArrayInputStream(binaryData);        if (null != binaryInput) {            ObjectInputStream in = new ObjectInputStream(binaryInput);            try {                obj = in.readObject();            } finally {                in.close();            }        }        return obj;    }    /**     * <p>     * This method should be overridden by any delegate subclasses that need     * special handling for BLOBs for job details. The default implementation     * uses standard JDBC <code>java.sql.Blob</code> operations.     * </p>     *      * @param rs     *          the result set, already queued to the correct row     * @param colName     *          the column name for the BLOB     * @return the deserialized Object from the ResultSet BLOB     * @throws ClassNotFoundException     *           if a class found during deserialization cannot be found     * @throws IOException     *           if deserialization causes an error     */    protected Object getJobDetailFromBlob(ResultSet rs, String colName)        throws ClassNotFoundException, IOException, SQLException {        //log.debug( "Getting Job details from blob in col " + colName );        if (canUseProperties()) {            byte data[] = rs.getBytes(colName);            if(data == null) {                return null;            }            InputStream binaryInput = new ByteArrayInputStream(data);            return binaryInput;        }        return getObjectFromBlob(rs, colName);    }}// EOF

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -