conn.setAutoCommit(false); try { stmt2 = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet res = stmt2.executeQuery("SELECT id,type,name,data FROM super_features WHERE chart_id = "+chart_id+" for update"); while (res.next()) { for (FeatureItem item : items) { if (item.getId() == res.getInt(1)) { res.updateInt(2, item.getType()); res.updateString(3, item.getName()); res.updateString(4, item.getData()); res.updateRow(); break; } } } res.close(); stmt2.close(); conn.commit(); conn.close(); } catch (SQLException e) { System.err.println("Error updating features"); throw e; } finally { try{conn.close();}catch(Exception e){} }