private void doClose() throws SQLException { m_dbUtils.cleanUp(); }
/** * <p>finalize</p> * @throws Throwable */ @Override protected void finalize() throws Throwable { m_dbUtils.cleanUp(); super.finalize(); }
/** {@inheritDoc} */ @Override protected void executeStmt(PreparedStatement stmt) throws SQLException { final DBUtils d = new DBUtils(getClass()); try { ResultSet rs = stmt.executeQuery(); d.watch(rs); m_count = 0; while (rs.next()) { m_rowProcessor.processRow(rs); m_count++; } } finally { d.cleanUp(); } }
private void doExecute(final Object[] values) throws SQLException { final DBUtils d = new DBUtils(getClass()); try { final Connection conn = m_db.getConnection(); d.watch(conn); final PreparedStatement stmt = conn.prepareStatement(m_sql); d.watch(stmt); for(int i = 0; i < values.length; i++) { stmt.setObject(i+1, values[i]); } executeStmt(stmt); } finally { d.cleanUp(); } }
LOG.warn("Caught SQLException while trying to query for all IP addresses: {}", sqle.getMessage()); } finally { d.cleanUp();
/** * This method queries the database in search of a service id for a given service name * * @param service * the name of the service * @return the serviceID of the service */ private int getServiceId(final String service) throws SQLException { int serviceID = 0; Connection connection = null; final DBUtils d = new DBUtils(getClass()); try { connection = getConnection(); d.watch(connection); final PreparedStatement statement = connection.prepareStatement("SELECT serviceID from service where serviceName = ?"); d.watch(statement); statement.setString(1, service); final ResultSet results = statement.executeQuery(); d.watch(results); if (!results.next()) { throw new SQLException("No serviceID found for service with serviceName: " + service); } serviceID = results.getInt(1); return serviceID; } finally { d.cleanUp(); } }
/** * This method determines what label should be associated with a particular * node. A database connection is retrieved from the Vault. * * WARNING: A properly instantiated and initialized Vault class object is * required prior to calling this method. This method will initially only be * called from the WEB UI. * * @param nodeID * Unique identifier of the node to be updated. * @return NodeLabel Object containing label and source values * @throws java.sql.SQLException if any. * * @deprecated Update this to use modern DAO methods instead of raw SQL */ public NodeLabel computeLabel(final int nodeID) throws SQLException { final Connection dbConnection = DataSourceFactory.getInstance().getConnection(); final DBUtils d = new DBUtils(NodeLabelJDBCImpl.class, dbConnection); try { return computeLabel(nodeID, dbConnection); } finally { d.cleanUp(); } }
/** * This method queries the 'node' table for the value of the 'nodelabel' and * 'nodelabelsource' fields for the node with the provided nodeID. A * NodeLabel object is returned initialized with the retrieved values. * * WARNING: A properly instantiated and initialized Vault class object is * required prior to calling this method. This method will initially only be * called from the WEB UI. * * @param nodeID * Unique identifier of the node to be updated. * @return Object containing label and source values. * @throws java.sql.SQLException if any. * * @deprecated Use a {@link NodeDao#load(Integer)} method call instead */ @Override public NodeLabel retrieveLabel(final int nodeID) throws SQLException { final Connection dbConnection = DataSourceFactory.getInstance().getConnection(); final DBUtils d = new DBUtils(NodeLabelJDBCImpl.class, dbConnection); try { return retrieveLabel(nodeID, dbConnection); } finally { d.cleanUp(); } }
/** * This method updates the 'nodelabel' and 'nodelabelsource' fields of the * 'node' table for the specified nodeID. A database connection is retrieved * from the Vault. * * WARNING: A properly instantiated and initialized Vault class object is * required prior to calling this method. This method will initially only be * called from the WEB UI. * * @param nodeID * Unique identifier of the node to be updated. * @param nodeLabel * Object containing label and source values. * @throws java.sql.SQLException if any. * * @deprecated Use a {@link NodeDao#update(org.opennms.netmgt.model.OnmsNode)} method call instead */ @Override public void assignLabel(final int nodeID, final NodeLabel nodeLabel) throws SQLException { final Connection dbConnection = DataSourceFactory.getInstance().getConnection(); final DBUtils d = new DBUtils(NodeLabelJDBCImpl.class, dbConnection); try { assignLabel(nodeID, nodeLabel, dbConnection); } finally { d.cleanUp(); } }
JasperFillManager.fillReportToFile(jasperReport, outputFileName, reportParms, connection); } finally { db.cleanUp();
throw new UndeclaredThrowableException(e); } finally { d.cleanUp();
JasperFillManager.fillReportToFile(jasperReport, outputFileName, reportParms, connection); } finally { db.cleanUp();
LOG.error("Error getting notice status", e); } finally { d.cleanUp();
@Override public Void call() throws Exception { final JasperReport jasperReport = getJasperReport(reportId); final Map<String, Object> jrReportParms = buildJRparameters(reportParms, jasperReport.getParameters()); jrReportParms.putAll(buildSubreport(reportId, jasperReport)); if ("jdbc".equalsIgnoreCase(m_globalReportRepository.getEngine(reportId))) { final DBUtils db = new DBUtils(); try { final Connection connection = DataSourceFactory.getInstance().getConnection(); db.watch(connection); final JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, jrReportParms, connection); exportReport(format, jasperPrint, outputStream); } finally { db.cleanUp(); } } else if ("null".equalsIgnoreCase(m_globalReportRepository.getEngine(reportId))) { final JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, jrReportParms, new JREmptyDataSource()); exportReport(format, jasperPrint, outputStream); } return null; } });
@Override public Void call() throws Exception { final JasperReport jasperReport = getJasperReport(reportId); final Map<String, Object> jrReportParms = buildJRparameters(reportParms, jasperReport.getParameters()); jrReportParms.putAll(buildSubreport(reportId, jasperReport)); if ("jdbc".equalsIgnoreCase(m_globalReportRepository.getEngine(reportId))) { final DBUtils db = new DBUtils(); try { final Connection connection = DataSourceFactory.getInstance().getConnection(); db.watch(connection); final JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, jrReportParms, connection); exportReport(format, jasperPrint, outputStream); } finally { db.cleanUp(); } } else if ("null".equalsIgnoreCase(m_globalReportRepository.getEngine(reportId))) { final JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, jrReportParms, new JREmptyDataSource()); exportReport(format, jasperPrint, outputStream); } return null; } });
dbUtils.cleanUp();