- GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("SELECT id, domainid, type, info FROM pingconfig WHERE id=?");
- ps.setInt(1, id);
-
- GigiResultSet rs = ps.executeQuery();
- if ( !rs.next()) {
- throw new IllegalArgumentException("Invalid pingconfig id " + id);
+ try (GigiPreparedStatement ps = new GigiPreparedStatement("SELECT `id`, `domainid`, `type`, `info` FROM `pingconfig` WHERE `id`=?")) {
+ ps.setInt(1, id);
+
+ GigiResultSet rs = ps.executeQuery();
+ if ( !rs.next()) {
+ throw new IllegalArgumentException("Invalid pingconfig id " + id);
+ }
+ this.id = rs.getInt("id");
+ target = Domain.getById(rs.getInt("domainid"));
+ type = DomainPingType.valueOf(rs.getString("type").toUpperCase());
+ info = rs.getString("info");