About setting the connection object to nothing

Source: Internet
Author: User
Here is a middle-layer component method. The transaction type is requirestransaction.
Public sub testinnerconn ()
Dim conn as ADODB. Connection
Dim conn1 as ADODB. Connection
Dim conn2 as ADODB. Connection
Dim conn3 as ADODB. Connection
Dim conn4 as ADODB. Connection
Dim conn5 as ADODB. Connection
Dim conn6 as ADODB. Connection
Dim rec as ADODB. recordset
Set conn = modvbmiddle. getconnectionobject ("hq_test ")
'App. logevent "Get the conn"
'Conn. Open
Set rec = conn. Execute ("select username, Sid, serial # from V $ session where username = 'pkuser '")
App. logevent "conn num:" + CSTR (Rec. recordcount)
Set conn = nothing
Sleep 5000
Set conn1 = modvbmiddle. getconnectionobject ("hq_test ")
Set rec = conn1.execute ("select username, Sid, serial # from V $ session where username = 'pkuser '")
App. logevent "conn num:" + CSTR (Rec. recordcount)
Set conn1 = nothing
Sleep 5000
Set conn2 = modvbmiddle. getconnectionobject ("hq_test ")
Set rec = conn2.execute ("select username, Sid, serial # from V $ session where username = 'pkuser '")
App. logevent "conn num:" + CSTR (Rec. recordcount)
Set conn2 = nothing
Sleep 5000
Set conn3 = modvbmiddle. getconnectionobject ("hq_test ")
Set rec = conn3.execute ("select username, Sid, serial # from V $ session where username = 'pkuser '")
App. logevent "conn num:" + CSTR (Rec. recordcount)
Set conn3 = nothing
Sleep 5000
Set conn4 = modvbmiddle. getconnectionobject ("hq_test ")
Set rec = conn4.execute ("select username, Sid, serial # from V $ session where username = 'pkuser '")
App. logevent "conn num:" + CSTR (Rec. recordcount)
Set conn4 = nothing
Sleep 5000
Set conn5 = modvbmiddle. getconnectionobject ("hq_test ")
Set rec = conn5.execute ("select username, Sid, serial # from V $ session where username = 'pkuser '")
App. logevent "conn num:" + CSTR (Rec. recordcount)
Set conn5 = nothing
Sleep 5000
Set conn6 = modvbmiddle. getconnectionobject ("hq_test ")
Set rec = conn6.execute ("select username, Sid, serial # from V $ session where username = 'pkuser '")
App. logevent "conn num:" + CSTR (Rec. recordcount)
Set conn6 = nothing
Sleep 5000
End sub

App. logevent writes the number of connections as a log.
The results surprised me that the number of connections found at one time was: 1, 2, 2, 2 ........
Connection. Close ensures that the connection is reused in the same transaction environment. If you only connect setnothing, you can only say that the connection is abnormal .....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.