- GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("INSERT INTO `notary` SET `from`=?, `to`=?, `points`=?, `location`=?, `date`=?");
- for (int i = 0; i < assurers.length; i++) {
- String mail = "test-assurer" + i + "@example.com";
- User u = User.getByEmail(mail);
- if (u == null) {
- System.out.println("Creating assurer");
- createUser(mail);
- u = User.getByEmail(mail);
- passCATS(u);
- ps.setInt(1, u.getId());
- ps.setInt(2, u.getId());
- ps.setInt(3, 100);
- ps.setString(4, "Manager init code");
- ps.setString(5, "1990-01-01");
- ps.execute();
- }
- assurers[i] = u;
+ try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `notary` SET `from`=?, `to`=?, `points`=?, `location`=?, `date`=?")) {
+ for (int i = 0; i < assurers.length; i++) {
+ String mail = "test-assurer" + i + "@example.com";
+ User u = User.getByEmail(mail);
+ if (u == null) {
+ System.out.println("Creating assurer");
+ createUser(mail);
+ u = User.getByEmail(mail);
+ passCATS(u);
+ ps.setInt(1, u.getId());
+ ps.setInt(2, u.getId());
+ ps.setInt(3, 100);
+ ps.setString(4, "Manager init code");
+ ps.setString(5, "1990-01-01");
+ ps.execute();
+ }
+ assurers[i] = u;