on 2020 Jun 16 6:53 AM
Hello, all I need to log durations and several other properties of all connections to the DB. I thought I would be able to use event type "disconnect", but it does not have parameter login time. Accessing the properties of the disconnected connection is, obviously, not possible.
Can someone tell me how I can do it?
Thank you Arcady
Request clarification before answering.
Here's a simple snippet, it just lists the according event parameters:
create event EV_Disconnect type "Disconnect" handler begin declare nConnId int; declare strUser varchar(128); declare strDisconnectReason varchar(128); set nConnId = event_parameter('ConnectionID'); set strUser = event_parameter('User'); set strDisconnectReason = event_parameter('DisconnectReason'); message 'EV_Disconnect for connection ' || nConnId || ' with user ' || strUser || ' and reason ' || strDisconnectReason || '.'; -- eventually log the user's disconnect time and reason in a user-defined table end;
We have used something like that in a combination with a login_procedure (you could also use a Connect event here) to log the connecting and disconnecting of users in the system by storing both in a user-defined table.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Would this event be triggered on pooled connection as well? I have a situation where all non pooled connections are registered correctly and the pooled are not registered at all or are registered after longer than a minute, whereas the client succeeded in 5-6 operations between these times.
Arcady
What kind of connection pooling do you use - SQL Anywhere's builtin facility via connection parameter CPOOL or via API (say, .NET)?
At least for the builtin pooling, according to the docs, disconnect and connect events also are fired for pooled connections (as expected because pooling should be transparent for the client). - I don't know whether this applies to pooling via API.
According to the ODBC logs, the pooling parameter is there: //------------------------------------- Attempting to connect using: UID=g4_api;PWD=**;DBN=G4_center6;ServerName=G4_center6;CON=G4_WebService_API(G4_IsSalesChannelConnectedToCustomer);INT=NO;LOG=C:\\Logger\\ODBC\\center6\\odbc.txt;CPOOL='YES(MaxCached=100)';Host=10.10.100.64
//--------------------------------------
User | Count |
---|---|
62 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.