/** * This method returns the next ID for a given sql. * * @param sql a java.lang.String. * @return a int. * @throws java.io.IOException if any. */ private int getNxtId(final String sql) throws SQLException { int id = 0; Connection connection = null; try { connection = getConnection(); Statement stmt = connection.createStatement(); ResultSet results = stmt.executeQuery(sql); results.next(); id = results.getInt(1); stmt.close(); results.close(); } finally { if (connection != null) { try { connection.close(); } catch (SQLException e) { } } } return id; }
final DBUtils d = new DBUtils(getClass()); try { connection = getConnection(); d.watch(connection); final PreparedStatement insert = connection.prepareStatement("INSERT INTO usersNotified (id, userid, notifyid, notifytime, media, contactinfo, autonotify) values (?,?,?,?,?,?,?)");
/** * 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(); } }
final DBUtils d = new DBUtils(getClass()); try { connection = getConnection(); d.watch(connection); final PreparedStatement statement = connection.prepareStatement("INSERT INTO notifications (" +
connection = getConnection(); d.watch(connection);
Connection connection = getConnection(); dbUtils.watch(connection); PreparedStatement statement = connection.prepareStatement(sql.toString());
final DBUtils d = new DBUtils(getClass()); try { connection = getConnection(); d.watch(connection); final PreparedStatement statement = connection.prepareStatement(getConfigManager().getConfiguration().getOutstandingNoticesSql());
Connection connection = getConnection(); dbUtils.watch(connection); PreparedStatement statement = connection.prepareStatement("SELECT e.eventId FROM events e, alarms a WHERE e.alarmid = a.alarmid AND a.reductionkey= ?");