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 .....