当前位置: 代码迷 >> Web前端 >> java 实施存储过程
  详细解决方案

java 实施存储过程

热度:119   发布时间:2012-09-02 21:00:34.0
java 执行存储过程

public void executeProcedure(HashMap map)throws DBException
?{
?
??Session session = HibernateSessionFactory.getInstance().getSession();
??Transaction tx = null;
??try
??{
???if(map != null)??
???{
????
????String begDatea = "";
????String begDateb = "";

????if(map.get("begDatea") != null)
?????begDatea = (String)map.get("begDatea");
????if(map.get("begDateb") != null)
?????begDateb = (String)map.get("begDateb");?
????System.out.println("Inproc.date:"+begDatea+"--"+begDateb);
????System.out.println("proc.date:"+begDatea+"--"+begDateb);
????tx = session.beginTransaction();?
????Connection con=session.connection();?
????String procedure = "{call statEnterpriseAttendProc(?,?)}";?
????CallableStatement cstmt = con.prepareCall(procedure);???
????cstmt.setString(1,begDatea);
????cstmt.setString(2,begDateb);
????cstmt.executeUpdate();
????tx.commit(); ????
????
???}
??
??}
??catch (Exception e)
??{
???e.printStackTrace();
???throw new DBException();
??}
?
?}

  相关解决方案