jsp中调用Bean然后在Bean中调用oracle存储过程
2008-05-13 16:08:31 来源:WEB开发网3、记录操作日志:
第一步,建立存储过程
create or replace procedure proc_writeNote(
description in varchar2,
wName in varchar2,
wIP in varchar2
)
is
begin
insert into Systemnote (Id,Description,Wname,Wip) values(Autoaddid.Nextval,description,wName,wIP);
commit;
end proc_writeNote;
第二步、建立操作存储过程的方法(重写prepareCall()方法)
public CallableStatement prepareCall(String produce){
try {
conn = DriverManager.getConnection(DBUrl, UserID, UserPWD);
cstmt=conn.prepareCall(produce);
}
catch (SQLException ex) {
System.err.print("prepareCall():"+ex.getMessage());
}
return cstmt;
}
第三步,执行存储过程
public void writeNote(String description,String wName,String wIP){
String sql="{call proc_writeNote(?,?,?)}";
try {
CallableStatement cstmt=conn.prepareCall(sql);
cstmt.setString(1, description);
cstmt.setString(2,wName);
cstmt.setString(3,wIP);
cstmt.executeUpdate();
}
catch (SQLException ex) {
System.out.print("writeNote():"+ex.getMessage());
}
}
更多精彩
赞助商链接