JSP调用存储过程

先看一个简单的例子,这里用的是PL/SQL   oracle 10g.

首先建立一个存储过程,用于删除用户及与用户相关的信息

create or replace procedure proc_person_data_clear(
usercode in varchar,unitcode in varchar,newDate in varchar)
/*usercode   删除人员的账号
  unitcode   删除人员所在的单位代码
  newDate    当前日期
*/
as
begin
   /*删除备忘录内当前人员的所有事项*/
  delete from pending_affairs where useraccount=usercode and systemcode=unitcode;
  /*删除文档管理内创建人为当前人员的且为个人文档*/
  delete from document_manager where doctype='0' and useraccount=usercode and systemcode=unitcode;
  /*删除当前人员的所有签到信息*/
  delete from person_sign_in where usercode=usercode and systemcode=unitcode;
  /*在用户管理内删除该人员账号*/
  delete from pub_person_manager  where useraccount=usercode and unit=unitcode;
end proc_person_data_clear;

 

然后在JSP页面调用该存储过程

 

 //连接数据库
 DbHandlerWithSharePool db = new DbHandlerWithSharePool();/*db是一个数据库连接对象*/
 if(db.open() == false){
   out.print(Tools.showMsg(GetErrDes.exDbCon));
       return;
 }
 Connection conn=db.getConn();

   db.beginTrans();
   CallableStatement stmt=conn.prepareCall("call proc_person_data_clear(?,?,?)");   //调用存储过程来进行人员数据的清理
   stmt.setString(1,useraccount);
   stmt.setString(2,cua.getSystemCode());
   stmt.setString(3,Tools.getDateString());
   stmt.execute();
    db.commit();
   stmt.close();

posted on 2008-03-03 22:11  一江水  阅读(4010)  评论(0编辑  收藏  举报