Ask a Question

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

SOLVED
MarcS
New Contributor

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?

5 REPLIES 5
Marsha_R
Community Hero

Here's an archived thread with a similar question.  If you are using a DDT driver, this may help.

https://community.smartbear.com/t5/TestComplete-Questions/Connection-to-DB-not-closing-properly/td-p...


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
AlexKaras
Community Hero

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.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

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

 

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?

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

Hi Alex, 

when I connect to this user with a database tool and then close the connection, then it works correctly. So I assume it has nothing to do with the Oracle configuration, otherwise I would expect the same behavior with these tools. Maybe it has to do with ADO or TestComplete

 

At the moment I have a good workaround, connecting with the system user.

But thanks anyway for your support.

 

Regards MarcS

cancel
Showing results for 
Search instead for 
Did you mean: