dx
02/16/2016, 10:45 PMpublic void delete(Event event) {
String query = "DELETE FROM Event WHERE id = ?;";
try (Connection c = connectionPoolService.getConnection();
PreparedStatement ps = c.prepareStatement(query)) {
ps.setLong(1, event.getId());
ps.executeUpdate();
} catch (SQLException ex) {
logger.error("Deleting event failed", ex);
}
}
Generated Kotlin code:
fun delete(event: Event) {
val query = "DELETE FROM Event WHERE id = ?;"
try {
connectionPoolService.connection.use { c ->
c.prepareStatement(query).use({ ps ->
ps.setLong(1, event.id)
ps.executeUpdate()
})
}
} catch (ex: SQLException) {
logger.error("Deleting event failed", ex)
}
}