2013-02-19 60 views
0

任何人都可以解釋如何將下面的代碼轉換爲JDK 7風格autoclosable ???java 7 closeable PreparedStatement

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); 
} 

回答

0

也發現,你不能使用之類的語句p.setObject(1,OBJ)的嘗試(...)