Re: get the sid,serial# of my connection?

From: <>
Date: Wed, 24 Dec 2008 08:42:02 GMT
Message-ID: <uBm4l.10181$>

Michel Cadot <micadot{at}altern{dot}org> wrote:
> "Mark D Powell" <> 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.

  1. a shell script to kill a connection:
        # 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,
                                   sys_context('USERENV', 'INSTANCE_NAME')
                            FROM dual""")
            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 Harrison
Pixar Animation Studios
Received on Wed Dec 24 2008 - 02:42:02 CST

Original text of this message