1 17 18 21 package org.quartz.impl.jdbcjobstore; 22 23 import java.sql.Connection ; 24 import java.sql.PreparedStatement ; 25 import java.sql.ResultSet ; 26 import java.sql.SQLException ; 27 28 import org.apache.commons.logging.Log; 29 30 37 public class DB2v6Delegate extends StdJDBCDelegate { 38 public static final String SELECT_NUM_JOBS = "SELECT COUNT(*) FROM " 39 + TABLE_PREFIX_SUBST + TABLE_JOB_DETAILS; 40 41 public static final String SELECT_NUM_TRIGGERS_FOR_JOB = "SELECT COUNT(*) FROM " 42 + TABLE_PREFIX_SUBST 43 + TABLE_TRIGGERS 44 + " WHERE " 45 + COL_JOB_NAME 46 + " = ? AND " + COL_JOB_GROUP + " = ?"; 47 48 public static final String SELECT_NUM_TRIGGERS = "SELECT COUNT(*) FROM " 49 + TABLE_PREFIX_SUBST + TABLE_TRIGGERS; 50 51 public static final String SELECT_NUM_CALENDARS = "SELECT COUNT(*) FROM " 52 + TABLE_PREFIX_SUBST + TABLE_CALENDARS; 53 54 public DB2v6Delegate(Log logger, String tablePrefix, String instanceId) { 55 super(logger, tablePrefix, instanceId); 56 } 57 58 public DB2v6Delegate(Log logger, String tablePrefix, String instanceId, 59 Boolean useProperties) { 60 super(logger, tablePrefix, instanceId, useProperties); 61 } 62 63 public int selectNumJobs(Connection conn) throws SQLException { 64 PreparedStatement ps = null; 65 ResultSet rs = null; 66 67 try { 68 int count = 0; 69 ps = conn.prepareStatement(rtp(SELECT_NUM_JOBS)); 70 rs = ps.executeQuery(); 71 72 if (rs.next()) { 73 count = rs.getInt(1); 74 } 75 76 return count; 77 } finally { 78 closeStatement(ps); 79 } 80 } 81 82 public int selectNumTriggersForJob(Connection conn, String jobName, 83 String groupName) throws SQLException { 84 PreparedStatement ps = null; 85 ResultSet rs = null; 86 87 try { 88 ps = conn.prepareStatement(rtp(SELECT_NUM_TRIGGERS_FOR_JOB)); 89 ps.setString(1, jobName); 90 ps.setString(2, groupName); 91 rs = ps.executeQuery(); 92 93 if (rs.next()) { 94 return rs.getInt(1); 95 } else { 96 return 0; 97 } 98 } finally { 99 closeStatement(ps); 100 } 101 } 102 103 public int selectNumTriggers(Connection conn) throws SQLException { 104 PreparedStatement ps = null; 105 ResultSet rs = null; 106 107 try { 108 int count = 0; 109 ps = conn.prepareStatement(rtp(SELECT_NUM_TRIGGERS)); 110 rs = ps.executeQuery(); 111 112 if (rs.next()) { 113 count = rs.getInt(1); 114 } 115 116 return count; 117 } finally { 118 closeStatement(ps); 119 } 120 } 121 122 public int selectNumCalendars(Connection conn) throws SQLException { 123 PreparedStatement ps = null; 124 ResultSet rs = null; 125 126 try { 127 int count = 0; 128 ps = conn.prepareStatement(rtp(SELECT_NUM_CALENDARS)); 129 rs = ps.executeQuery(); 130 131 if (rs.next()) { 132 count = rs.getInt(1); 133 } 134 135 return count; 136 } finally { 137 closeStatement(ps); 138 } 139 } 140 } 141 142 | Popular Tags |