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

📄 db2v6delegate.java

📁 定时器开源项目, 相对于 jcrontab, Quartz 算是更完整的一个项目, 随著开发的版本上来, 他已经脱离只是写在程序里面的计时器, 在指定的时间或区间, 处理所指定的事件. 也加入了 se
💻 JAVA
字号:
/* * Copyright James House (c) 2001-2004 *  * All rights reserved. *  * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: 1. * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. 2. Redistributions in * binary form must reproduce the above copyright notice, this list of * conditions and the following disclaimer in the documentation and/or other * materials provided with the distribution. *  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *   */package org.quartz.impl.jdbcjobstore;import java.sql.Connection;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import org.apache.commons.logging.Log;/** * Quartz JDBC delegate for DB2 v6 databases. <code>select count(name)</code> * had to be replaced with <code>select count(*)</code>. *  * @author Martin Renner */public class DB2v6Delegate extends StdJDBCDelegate {    public static final String SELECT_NUM_JOBS = "SELECT COUNT(*) FROM "            + TABLE_PREFIX_SUBST + TABLE_JOB_DETAILS;    public static final String SELECT_NUM_TRIGGERS_FOR_JOB = "SELECT COUNT(*) FROM "            + TABLE_PREFIX_SUBST            + TABLE_TRIGGERS            + " WHERE "            + COL_JOB_NAME            + " = ? AND " + COL_JOB_GROUP + " = ?";    public static final String SELECT_NUM_TRIGGERS = "SELECT COUNT(*) FROM "            + TABLE_PREFIX_SUBST + TABLE_TRIGGERS;    public static final String SELECT_NUM_CALENDARS = "SELECT COUNT(*) FROM "            + TABLE_PREFIX_SUBST + TABLE_CALENDARS;    public DB2v6Delegate(Log logger, String tablePrefix, String instanceId) {        super(logger, tablePrefix, instanceId);    }    public DB2v6Delegate(Log logger, String tablePrefix, String instanceId,            Boolean useProperties) {        super(logger, tablePrefix, instanceId, useProperties);    }    public int selectNumJobs(Connection conn) throws SQLException {        PreparedStatement ps = null;        ResultSet rs = null;        try {            int count = 0;            ps = conn.prepareStatement(rtp(SELECT_NUM_JOBS));            rs = ps.executeQuery();            if (rs.next()) {                count = rs.getInt(1);            }            return count;        } finally {            close(ps);        }    }    public int selectNumTriggersForJob(Connection conn, String jobName,            String groupName) throws SQLException {        PreparedStatement ps = null;        ResultSet rs = null;        try {            ps = conn.prepareStatement(rtp(SELECT_NUM_TRIGGERS_FOR_JOB));            ps.setString(1, jobName);            ps.setString(2, groupName);            rs = ps.executeQuery();            if (rs.next()) {                return rs.getInt(1);            } else {                return 0;            }        } finally {            close(ps);        }    }    public int selectNumTriggers(Connection conn) throws SQLException {        PreparedStatement ps = null;        ResultSet rs = null;        try {            int count = 0;            ps = conn.prepareStatement(rtp(SELECT_NUM_TRIGGERS));            rs = ps.executeQuery();            if (rs.next()) {                count = rs.getInt(1);            }            return count;        } finally {            close(ps);        }    }    public int selectNumCalendars(Connection conn) throws SQLException {        PreparedStatement ps = null;        ResultSet rs = null;        try {            int count = 0;            ps = conn.prepareStatement(rtp(SELECT_NUM_CALENDARS));            rs = ps.executeQuery();            if (rs.next()) {                count = rs.getInt(1);            }            return count;        } finally {            close(ps);        }    }    private void close(Statement stmt) {        if (stmt != null) {            try {                stmt.close();            } catch (SQLException ignore) {            }        }    }}// EOF

⌨️ 快捷键说明

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