public void executeProc(int procId,String param) throws InvalidRowColException, ColumnTypeNotMatchException, IOException, SQLException {
String sql = "select t.proc_name_eng procName from dw.dw_proc_manger t where t.proc_id = " +procId;
Datastore ds = dc.retrieve(sql);
String procName = ds.getItemString(1, "procName");
StringBuffer exeSql = new StringBuffer();
exeSql.append("DECLARE X NUMBER;BEGIN SYS.DBMS_JOB.SUBMIT( job => X,what => '");
exeSql.append(procName);
exeSql.append("(''"+param+"'');',next_date => sysdate,no_parse => FALSE);END;");
log4j.info(exeSql);
Connection conn = null;
Statement stmt = null;
try{
conn = JDBCUtil.getConnection();
stmt = conn.createStatement();
int flag = stmt.executeUpdate(exeSql.toString());
conn.commit();
log4j.info("flag:"+flag);
}finally{
if (stmt != null) {
stmt.close();
}
if (conn != null) {
conn.close();
}
}
log4j.info("execute success...");
}
String sql = "select t.proc_name_eng procName from dw.dw_proc_manger t where t.proc_id = " +procId;
Datastore ds = dc.retrieve(sql);
String procName = ds.getItemString(1, "procName");
StringBuffer exeSql = new StringBuffer();
exeSql.append("DECLARE X NUMBER;BEGIN SYS.DBMS_JOB.SUBMIT( job => X,what => '");
exeSql.append(procName);
exeSql.append("(''"+param+"'');',next_date => sysdate,no_parse => FALSE);END;");
log4j.info(exeSql);
Connection conn = null;
Statement stmt = null;
try{
conn = JDBCUtil.getConnection();
stmt = conn.createStatement();
int flag = stmt.executeUpdate(exeSql.toString());
conn.commit();
log4j.info("flag:"+flag);
}finally{
if (stmt != null) {
stmt.close();
}
if (conn != null) {
conn.close();
}
}
log4j.info("execute success...");
}
本文介绍了一段Java代码,该代码通过连接数据库并使用SYS.DBMS_JOB.SUBMIT过程来执行指定ID的存储过程。代码首先从数据仓库中检索对应于给定过程ID的存储过程名称,然后构造并执行一个PL/SQL块来提交作业。
1154

被折叠的 条评论
为什么被折叠?



