我想通过调用下面的过程并传递作业 ID、会话 ID 和会话序列号等参数来从 Java 应用程序中终止一些作业。它行不通,我在这里很迷茫。
PROCEDURE kill_batch_test (
V_JOB IN VARCHAR2,
V_SID IN VARCHAR2,
V_SERIAL IN VARCHAR2 )
IS
BEGIN
DBMS_JOB.REMOVE(V_JOB);
execute immediate 'Alter System Kill Session '''|| to_char (V_SID) || ',' || to_char (V_SERIAL) || ''' IMMEDIATE';
EXCEPTION
WHEN OTHERS THEN
RETURN;
END;
[编辑]
java代码:这让我得到了用户工作:
String sql1 = "select sid SID, username, serial# SERIAL,j.job JOB, WHAT from (select dj.LOG_USER, dj.JOB, dj.BROKEN, dj.FAILURES, dj.LAST_DATE,dj.LAST_SEC, dj.THIS_DATE, dj.THIS_SEC, dj.NEXT_DATE, dj.NEXT_SEC, dj.INTERVAL, dj.WHAT from dba_jobs dj ) j,(select p.spid, s.username, s.sid, s.serial# from v$process p, v$session s where p.addr = s.paddr AND s.username = 'EPS') s ";
SQLQuery res = (SQLQuery) session.createSQLQuery(sql1).setCacheable(false);
res.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
List e = res.list();
Object o;
Iterator it = e.iterator();
for(int i=0;i<e.size();i++){
o = it.next();
Map m = (Map)o;
String sid = null;
String serial = null;
String job = null;
sid = m.get("SID").toString();
serial = m.get("SERIAL").toString();
job = m.get("JOB").toString();
我在这里调用程序:
CallableStatement storedProc = hibConnection.prepareCall(sql);
storedProc.setString(1,job);
storedProc.setString(2,sid);
storedProc.setString(3,serial);
storedProc.executeUpdate();
}