title: How to use procedure to kill jobs calling it from java code?
body: <p>I want to kill some jobs from a java app by calling the procedure below and passing the parameters which are job id, session id and session serial number. It won't work  and I am very lost here. </p>
  
  <pre><code>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; 
  </code></pre>
  
  <p><strong>[EDIT]</strong></p>
  
  <p>The java code : 
  This gets me the user jobs : </p>
  
  <pre><code>    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&lt;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();
  </code></pre>
  
  <p>here I call the procedure : </p>
  
  <pre><code>    CallableStatement storedProc = hibConnection.prepareCall(sql);
      storedProc.setString(1,job);
      storedProc.setString(2,sid);
      storedProc.setString(3,serial);
      storedProc.executeUpdate();
  }
  </code></pre>