`
hougbin
  • 浏览: 493631 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

hibernate 存储过程

    博客分类:
  • ssh
阅读更多
  1. import java.sql.CallableStatement;   
  2. import java.sql.Connection;   
  3. import org.apache.log4j.Logger;   
  4. import org.hibernate.classic.Session;   
  5.   
  6. import com.check.base.BaseHibernate;   
  7. import com.check.collection.dao.CollectionDao;   
  8.   
  9. public class CollectionHibernate extends BaseHibernate implements CollectionDao {   
  10. private Logger logger = Logger.getLogger(CollectionHibernate.class);   
  11. /* 采集OBDATA  
  12. */  
  13. public boolean getOBData(String oldtime,String citytype, String cityType, String deptmentIds) throws Exception {   
  14.    // TODO 采集   
  15.   
  16. logger.info("CollectionHibernate getOBData is Begin...");   
  17.    boolean bool = false;   
  18.    CallableStatement stmt = null;   
  19.    Connection conn = null;   
  20.    Session session = null;   
  21.    try{   
  22.     session = this.getHibernateTemplate().getSessionFactory().openSession();   
  23.     conn = session.connection();   
  24.     stmt = conn.prepareCall("{call Proc_GETLINKDATA(?,?)}");   
  25.     stmt.setString(1,oldtime);   
  26.     stmt.setString(2,citytype);   
  27.     stmt.execute();   
  28.       
  29.     if (deptmentIds.length() > 0) {   
  30.      stmt = conn.prepareCall("{call DATADELETEBYDATEANDDEPT(?, ?, ?)}");   
  31.      stmt.setString(1"");   
  32.      stmt.setString(2, deptmentIds);   
  33.      stmt.setString(3, cityType);   
  34.      stmt.execute();   
  35.     }   
  36.       
  37.     conn.commit();   
  38.     bool = true;   
  39.    }catch(Exception e){   
  40.     e.printStackTrace();   
  41.     conn.rollback();   
  42.    }finally{   
  43.     if (session != null) {   
  44.      session.close();   
  45.     }   
  46.    }   
  47.    logger.info("CollectionHibernate getOBData is End...");   
  48.    return bool;   
  49. }   
  50.   
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics