谁能解释如何将以下代码转换为 JDK 7 风格的自动关闭?
PreparedStatement p = = conn.prepareStatement("INSERT INTO myTable(colName) VALUES(?)", Statement.RETURN_GENERATED_KEYS);
p.setObject(1, obj);
int r = p.executeUpdate();
ResultSet rs = p.getGeneratedKeys();
if (null != rs && rs.next()) {
activityInfoId = rs.getLong(1);
}