Forum Discussion

MarcS's avatar
MarcS
Occasional Contributor
3 years ago

ADO: Connection to the database still exists, after calling connection.close (Oracle)

If I execute the following code snipped, the user for the ADO connection is still connected to the database in the background. I'm not able to delete the database scheme for this user, after closing the connection. Oralce throws the error: ora-01940 cannot drop a user that is currently connected

 

  • var QryConnection = ADO["CreateConnection"]();
    QryConnection["ConnectionString"] = "Data Source="+"TNSName"+";User Id="+"UID" + ";Password="+"PWD";
    QryConnection["Open"]();
    QryConnection["Close"]();

 

Only when my tests have been run and the execution is finished, the connection will be closed completely.

 

In the ADO documentation I've found this:

"To completely eliminate an object from memory, close the object and then set the object variable to Nothing (in Visual Basic)."

 

I've tried to set QryConnection to undefined or null after calling close, but the connection was still available.

 

If I execute the following query in Oracle, I can see the connection, despite calling connection.close:

  • select s.sid, s.serial#, s.status, p.spid
    from v$session s, v$process p
    where Upper(s.username) = 'XXX'
    and p.addr (+) = s.paddr;

What can I do, that after closing a connection, the access to the databse will be released?

  • MarcS's avatar
    MarcS
    3 years ago

    Hi Alex,

    thank you for your reply.

    The hint with the garbage collection would fit with the following, which I've found out in the meantime.

    After a 2 minute wait, the connection is terminated. But the variable is only defined within the function.

     

    I was able to solve my problem first by using the user SYSTEM. This way I have no connection to the schema, which I first query and then possibly delete.

     

    It would be interesting to see what happens, If I could call the "collect function" of the garbage collection from TestComplete

     

    Regards MarcS

     

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    The only idea that I have at the moment is that QryConnection variable is a public one (or was copied to a public one) and thus was not garbage collected which keeps connection on the database side to be not disposed of.

     

    • MarcS's avatar
      MarcS
      Occasional Contributor

      Hi Alex,

      thank you for your reply.

      The hint with the garbage collection would fit with the following, which I've found out in the meantime.

      After a 2 minute wait, the connection is terminated. But the variable is only defined within the function.

       

      I was able to solve my problem first by using the user SYSTEM. This way I have no connection to the schema, which I first query and then possibly delete.

       

      It would be interesting to see what happens, If I could call the "collect function" of the garbage collection from TestComplete

       

      Regards MarcS

       

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Hi,

         

        Might it be that this is something in Oracle (or how TNS is configured) itself that keeps its internal connection object in a pool for this 2 minutes timeout? Can you check this idea with your Oracle administrators?