赵王涛笔记 java调用数据库存储过程
public String callProcedure(String processtname, String isoverwrite,
String isrecollect, String bdate, String edate, String createdate,
String datecol) throws Exception {
String processresult = "";
try {
CallableStatement proc = null;
proc = conn.prepareCall("{ CALL PROCESSDATA(?,?,?,?,?,?,?,?) }");
proc.setString(1, processtname);
proc.setString(2, isoverwrite);
proc.setString(3, isrecollect);
proc.setString(4, bdate);
proc.setString(5, edate);
proc.setString(6, createdate);
proc.setString(7, datecol);
proc.registerOutParameter(8, Types.VARCHAR);
System.out.println("procedure 1:"+processtname);
System.out.println("procedure 2:"+isoverwrite);
System.out.println("procedure 3:"+isrecollect);
System.out.println("procedure 4:"+bdate);
System.out.println("procedure 5:"+edate);
System.out.println("procedure 6:"+createdate);
System.out.println("procedure 7:"+datecol);
proc.execute();
processresult = proc.getString(8);
} finally {
if (conn != null) {
conn.close();
}
}
return processresult;
}
exception
processresult := SQLERRM; 执行存储过程的异常信息