public static String updateEvent(String dataXml) {
Session session = HibernateUtils.getNewSession();
Connection con = null;
PreparedStatement pstmt = null;
try {
con = session.connection();
con.setAutoCommit(false);
Document doc = org.trundle.common.XmlUtils.createDocument(dataXml);
Element root = doc.getRootElement();
List elements = root.elements();
if (elements.size() == 0) {
return "1";
}
for (int i = 0; i < elements.size(); i++) {
Element ele = (Element) elements.get(i);
Iterator attItr = ele.attributeIterator();
String jd = "";
String yjzfresul = "";
String id = "";
while (attItr.hasNext()) {
DefaultAttribute att = (DefaultAttribute) attItr.next();
if ("jianduan".equals(att.getName())) {
jd = att.getValue();
}
if ("dealresult".equals(att.getName())) {
yjzfresul = att.getValue();
}
if ("cgid".equals(att.getName())) {
id = att.getValue();
}
}
String sql = "update t_event set c_yjzfjd='" + jd + "',c_yjzfresult='" +
yjzfresul + "' where id='" + id + "'";
pstmt = con.prepareStatement(sql);
pstmt.executeUpdate();
}
con.commit();
}
catch (Exception e) {
e.printStackTrace();
return "0";
}
finally {
try {
pstmt.close();
con.close();
}
catch (Exception e1) {}
if (session != null) {
session.close();
}
}
return "1";
}
阅读(293) | 评论(0) | 转发(0) |