Chinaunix首页 | 论坛 | 博客
  • 博客访问: 76577
  • 博文数量: 59
  • 博客积分: 2510
  • 博客等级: 少校
  • 技术积分: 610
  • 用 户 组: 普通用户
  • 注册时间: 2010-01-04 11:03
文章分类
文章存档

2010年(59)

我的朋友

分类: 系统运维

2010-03-22 21:16:05

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";
}
阅读(284) | 评论(0) | 转发(0) |
0

上一篇:周末的学习

下一篇:嘿嘿 今天不错

给主人留下些什么吧!~~