Re: get the sid,serial# of my connection?
From: <mh_at_pixar.com>
Date: Wed, 24 Dec 2008 08:42:02 GMT
Message-ID: <uBm4l.10181$Ei5.8271@flpi143.ffdc.sbc.com>
Date: Wed, 24 Dec 2008 08:42:02 GMT
Message-ID: <uBm4l.10181$Ei5.8271@flpi143.ffdc.sbc.com>
Michel Cadot <micadot{at}altern{dot}org> wrote:
> "Mark D Powell" <Mark.Powell_at_eds.com> a ?crit dans le message de news:
>> Hey, I learned something new. thanks Laurenz.
> So do I
Thanks all... here's my results which are working great.
- a shell script to kill a connection:
#!/bin/sh
# kill a specified oracle session
sid=$1; ser=$2; inst=$3
echo -n sys password:
stty -echo; read pass; stty echo
echo "alter system kill session '$sid,$ser';"|
sqlplus -SL sys/$pass@$inst as sysdba
2. a local function (this in python) to generate a call to this script.
I call this at the beginning of my test program and print the string so I can cut and paste.
def killstring(curs):
"""return a string that will kill this db connection"""
curs.execute("""SELECT dbms_debug_jdwp.current_session_id,
dbms_debug_jdwp.current_session_serial,
sys_context('USERENV', 'INSTANCE_NAME')
FROM dual""")
(sid,serial,instance)=curs.fetchone()
s="oracle-killsession %s %s %s"%(sid,serial,instance)
return s
3. and a sample invocation
ohm ~/tst$ oracle-killsession 98 45809 tmpltest2
sys password:
System altered.
4. and from my client... hooray!!!
cx_Oracle.DatabaseError: ORA-00028: your session has been killed
Share and enjoy!
Mark
-- Mark Harrison Pixar Animation StudiosReceived on Wed Dec 24 2008 - 02:42:02 CST
