- GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("INSERT INTO `jobs` SET targetId=?, task=?::`jobType`, executeFrom=?, executeTo=?");
- ps.setInt(1, targetId.getId());
- ps.setString(2, JobType.SIGN.getName());
- ps.setDate(3, start);
- ps.setString(4, period);
- ps.execute();
- return new Job(ps.lastInsertId());
+ try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `jobs` SET targetId=?, task=?::`jobType`, executeFrom=?, executeTo=?")) {
+ ps.setInt(1, targetId.getId());
+ ps.setEnum(2, JobType.SIGN);
+ ps.setDate(3, start);
+ ps.setString(4, period);
+ ps.execute();
+ return cache.put(new Job(ps.lastInsertId()));
+ }