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();
  }
 
 }

你可能感兴趣的:(java)