本文整理了Java中org.miloss.fgsms.common.DBUtils.safeClose()
方法的一些代码示例,展示了DBUtils.safeClose()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DBUtils.safeClose()
方法的具体详情如下:
包路径:org.miloss.fgsms.common.DBUtils
类名称:DBUtils
方法名:safeClose
暂无
代码示例来源:origin: org.mil-oss/fgsms-stats
private double getAvgCPU(final String url, final Long ts, Connection con) {
double r = 0;
PreparedStatement cmd = null;
ResultSet rs = null;
try {
cmd = con.prepareStatement("select avg(percentcpu) from rawdatamachineprocess where uri=? and utcdatetime > ?");
cmd.setString(1, url);
cmd.setLong(2, System.currentTimeMillis() - ts);
rs = cmd.executeQuery();
if (rs.next()) {
r = rs.getLong(1);
}
} catch (Exception ex) {
log.log(Level.ERROR, null, ex);
} finally {
DBUtils.safeClose(rs);
DBUtils.safeClose(cmd);
}
return r;
}
代码示例来源:origin: org.mil-oss/fgsms-dependency-scanner
private void RecordDependency(String url, String action, String url0, String action0, Connection con) {
PreparedStatement cmd=null;
try {
cmd = con.prepareStatement("INSERT INTO dependencies(sourceurl, sourcesoapaction, destintationurl, destinationsoapaction) VALUES (?, ?, ?, ?);");
cmd.setString(1, url);
cmd.setString(2, action);
cmd.setString(3, url0);
cmd.setString(4, action0);
cmd.executeUpdate();
} catch (Exception ex) {
log.log(Level.ERROR, null, ex);
} finally {
DBUtils.safeClose(cmd);
}
}
代码示例来源:origin: org.mil-oss/fgsms-stats
private long getMaxQueueDepth(final String url, final Long ts, Connection con) {
long r = 0;
PreparedStatement cmd = null;
ResultSet rs = null;
try {
cmd = con.prepareStatement("select max(queuedepth) from brokerhistory where host=? and utcdatetime > ?");
cmd.setString(1, url);
cmd.setLong(2, System.currentTimeMillis() - ts);
rs = cmd.executeQuery();
if (rs.next()) {
r = rs.getLong(1);
}
} catch (Exception ex) {
log.log(Level.ERROR, null, ex);
} finally {
DBUtils.safeClose(rs);
DBUtils.safeClose(cmd);
}
return r;
}
代码示例来源:origin: org.mil-oss/fgsms-stats
private long getMessagesOut(String url, Long ts, Connection con) {
long r = 0;
PreparedStatement cmd = null;
ResultSet rs = null;
try {
cmd = con.prepareStatement("select avg(messagecount) from brokerhistory where host=? and utcdatetime > ?");
cmd.setString(1, url);
cmd.setLong(2, System.currentTimeMillis() - ts);
rs = cmd.executeQuery();
if (rs.next()) {
r = rs.getLong(1);
}
} catch (Exception ex) {
log.log(Level.ERROR, null, ex);
} finally {
DBUtils.safeClose(rs);
DBUtils.safeClose(cmd);
}
return r;
}
代码示例来源:origin: org.mil-oss/fgsms-stats
private long getMessagesDropped(final String url, final Long ts, Connection con) {
long r = 0;
PreparedStatement cmd = null;
ResultSet rs = null;
try {
cmd = con.prepareStatement("select avg(messagedropcount) from brokerhistory where host=? and utcdatetime > ?");
cmd.setString(1, url);
cmd.setLong(2, System.currentTimeMillis() - ts);
rs = cmd.executeQuery();
if (rs.next()) {
r = rs.getLong(1);
}
} catch (Exception ex) {
log.log(Level.ERROR, null, ex);
} finally {
DBUtils.safeClose(rs);
DBUtils.safeClose(cmd);
}
return r;
}
private void doWorkBrokers(Connection ConfigCon, Connection PerfCon, List<Long> periods) throws Exception {
代码示例来源:origin: org.mil-oss/fgsms-stats
private long getAvgMem(final String url, final Long ts, Connection con) {
Double r = Double.valueOf(0);
PreparedStatement cmd = null;
ResultSet rs = null;
try {
cmd = con.prepareStatement("select avg(memoryused) from rawdatamachineprocess where uri=? and utcdatetime > ?");
cmd.setString(1, url);
cmd.setLong(2, System.currentTimeMillis() - ts);
rs = cmd.executeQuery();
if (rs.next()) {
r = rs.getDouble(1);
}
} catch (Exception ex) {
log.log(Level.ERROR, null, ex);
} finally {
DBUtils.safeClose(rs);
DBUtils.safeClose(cmd);
}
return r.longValue();
}
代码示例来源:origin: org.mil-oss/fgsms-stats
private long getAvgFile(final String url, final Long ts, Connection con) {
Double r = Double.valueOf(0);
PreparedStatement cmd = null;
ResultSet rs = null;
try {
cmd = con.prepareStatement("select avg(openfiles) from rawdatamachineprocess where uri=? and utcdatetime > ?");
cmd.setString(1, url);
cmd.setLong(2, System.currentTimeMillis() - ts);
rs = cmd.executeQuery();
if (rs.next()) {
r = rs.getDouble(1);
}
} catch (Exception ex) {
log.log(Level.ERROR, null, ex);
} finally {
DBUtils.safeClose(rs);
DBUtils.safeClose(cmd);
}
return r.longValue();
}
代码示例来源:origin: org.mil-oss/fgsms-report-generator
private void updateLastRanAt(ReportDefinition get) {
Connection con = Utility.getPerformanceDBConnection();
PreparedStatement cmd = null;
try {
cmd = con.prepareStatement("update arsjobs set lastranat=? where jobid=?");
cmd.setLong(1, System.currentTimeMillis());
cmd.setString(2, get.getJobId());
cmd.executeUpdate();
} catch (Exception ex) {
log.log(Level.WARN, null, ex);
} finally {
DBUtils.safeClose(cmd);
DBUtils.safeClose(con);
}
}
}
代码示例来源:origin: org.mil-oss/fgsms-sla-processor
/**
* returns all of the mail settings, use from nonpooled connections,
* connections loaded from properties file in common
*
* @return
*/
@Deprecated
public static Properties LoadSLAPropertiesNotPooled() {
Connection con = Utility.getConfigurationDB_NONPOOLED_Connection();
Properties p = loadSLAProperties(con);
DBUtils.safeClose(con);
return p;
}
代码示例来源:origin: org.mil-oss/fgsms-sla-processor
/**
* returns all of the mail settings, use from pooled connections with jndi
*
* @return
*/
public static Properties LoadSLAPropertiesPooled() {
Connection con = Utility.getConfigurationDBConnection();
Properties p = loadSLAProperties(con);
DBUtils.safeClose(con);
return p;
}
代码示例来源:origin: org.mil-oss/fgsms-sla-processor
@Deprecated
public static InternetAddress[] GetAllfgsmsAdminsEmailAddressNotPooled() {
SetupBundle();
Connection con = Utility.getConfigurationDB_NONPOOLED_Connection();
InternetAddress[] sp = getAllfgsmsAdminsEmailAddress(con);
DBUtils.safeClose(con);
return sp;
}
代码示例来源:origin: org.mil-oss/fgsms-stats
@Override
public void run() {
UUID random = UUID.randomUUID();
MessageProcessor.getSingletonObject().processMessageInput(SERVICE_NAME, 0, myUrl, "machine/process", "system", random.toString(), new HashMap(), "", this.getClass().getCanonicalName(), "", "");
Connection ConfigCon = Utility.getConfigurationDBConnection();
Connection PerfCon = Utility.getPerformanceDBConnection();
try {
doWorkBrokers(ConfigCon, PerfCon, periods);
MessageProcessor.getSingletonObject().processMessageOutput(random.toString(), "success", 0, false, System.currentTimeMillis(), new HashMap());
} catch (Exception ex) {
MessageProcessor.getSingletonObject().processMessageOutput(random.toString(), "error " + ex.getMessage(), 0, true, System.currentTimeMillis(), new HashMap());
} finally {
DBUtils.safeClose(PerfCon);
DBUtils.safeClose(ConfigCon);
}
}
代码示例来源:origin: org.mil-oss/fgsms-stats
@Override
public void run() {
UUID random = UUID.randomUUID();
MessageProcessor.getSingletonObject().processMessageInput(SERVICE_NAME, 0, myUrl, "machine/process", "system", random.toString(), new HashMap(), "", this.getClass().getCanonicalName(), "", "");
Connection ConfigCon = Utility.getConfigurationDBConnection();
Connection PerfCon = Utility.getPerformanceDBConnection();
try {
doWorkMachinesProcesses(ConfigCon, PerfCon, periods);
MessageProcessor.getSingletonObject().processMessageOutput(random.toString(), "success", 0, false, System.currentTimeMillis(), new HashMap());
} catch (Exception ex) {
MessageProcessor.getSingletonObject().processMessageOutput(random.toString(), "error " + ex.getMessage(), 0, true, System.currentTimeMillis(), new HashMap());
} finally {
DBUtils.safeClose(PerfCon);
DBUtils.safeClose(ConfigCon);
}
}
代码示例来源:origin: org.mil-oss/fgsms-stats
@Override
public void run() {
UUID random = UUID.randomUUID();
MessageProcessor.getSingletonObject().processMessageInput(SERVICE_NAME, 0, myUrl, "status", "system", random.toString(), new HashMap(), "", this.getClass().getCanonicalName(), "", "");
Connection ConfigCon = Utility.getConfigurationDBConnection();
Connection PerfCon = Utility.getPerformanceDBConnection();
try {
doWorkForStatusItemsOnly(ConfigCon, PerfCon, periods);
MessageProcessor.getSingletonObject().processMessageOutput(random.toString(), "success", 0, false, System.currentTimeMillis(), new HashMap());
} catch (Exception ex) {
MessageProcessor.getSingletonObject().processMessageOutput(random.toString(), "error " + ex.getMessage(), 0, true, System.currentTimeMillis(), new HashMap());
log.log(Level.ERROR, null, ex);
} finally {
DBUtils.safeClose(PerfCon);
DBUtils.safeClose(ConfigCon);
}
}
代码示例来源:origin: org.mil-oss/fgsms-stats
@Override
public void run() {
UUID random = UUID.randomUUID();
MessageProcessor.getSingletonObject().processMessageInput(SERVICE_NAME + " for " + uri, 0, myUrl, "transactional", "system", random.toString(), new HashMap(), "", this.getClass().getCanonicalName(), "", "");
Connection ConfigCon = Utility.getConfigurationDBConnection();
Connection PerfCon = Utility.getPerformanceDBConnection();
try {
doWorkTransactional(ConfigCon, PerfCon, periods, uri);
MessageProcessor.getSingletonObject().processMessageOutput(random.toString(), "success", 0, false, System.currentTimeMillis(), new HashMap());
} catch (Exception ex) {
MessageProcessor.getSingletonObject().processMessageOutput(random.toString(), "error " + ex.getMessage(), 0, true, System.currentTimeMillis(), new HashMap());
log.log(Level.ERROR, null, ex);
} finally {
DBUtils.safeClose(PerfCon);
DBUtils.safeClose(ConfigCon);
}
}
代码示例来源:origin: org.mil-oss/fgsms-sla-processor
/**
* used by qpid agents
*
* @param uRI
* @return
*/
@Deprecated
public static ServicePolicy LoadPolicyNotPooled(String uRI) {
SetupBundle();
Connection con = Utility.getConfigurationDB_NONPOOLED_Connection();
ServicePolicy sp = loadPolicy(con, uRI);
DBUtils.safeClose(con);
return sp;
}
代码示例来源:origin: org.mil-oss/fgsms-sla-processor
/**
* Returns a list of user's email addresses that are subscribed to a
* specific SLA with email actions
*
* @param guid
* @return
*/
@Deprecated
public static InternetAddress[] GetSubscribersNotPooled(String guid) {
SetupBundle();
Connection con = Utility.getConfigurationDB_NONPOOLED_Connection();
InternetAddress[] sp = getSubscribers(con, guid);
DBUtils.safeClose(con);
return sp;
}
代码示例来源:origin: org.mil-oss/fgsms-sla-processor
public static InternetAddress[] GetAllfgsmsAdminsEmailAddressPooled() {
SetupBundle();
Connection con = Utility.getConfigurationDBConnection();
InternetAddress[] sp = getAllfgsmsAdminsEmailAddress(con);
DBUtils.safeClose(con);
return sp;
}
代码示例来源:origin: org.mil-oss/fgsms-sla-processor
/**
* Returns a list of user's email addresses that are subscribed to a
* specific SLA with email actions
*
* @param guid
* @return
*/
public static InternetAddress[] GetSubscribersPooled(String guid) {
SetupBundle();
Connection con = Utility.getConfigurationDBConnection();
InternetAddress[] sp = getSubscribers(con, guid);
DBUtils.safeClose(con);
return sp;
}
代码示例来源:origin: org.mil-oss/fgsms-sla-processor
/**
* used by NT SLA for web services
*
* @return
*/
public static List<ServicePolicy> LoadServicePoliciesNotPooled() {
Connection con = Utility.getConfigurationDB_NONPOOLED_Connection();
SetupBundle();
List<ServicePolicy> r = null;
try {
r = loadServicePolicies(con);
} catch (Exception ex) {
log.log(Level.ERROR, bundle.getString("ErrorLoadingPolicy"), ex);
} finally {
DBUtils.safeClose(con);
}
if (r == null) {
r = new ArrayList<ServicePolicy>();
}
return r;
}
内容来源于网络,如有侵权,请联系作者删除!