discover number of active connections [SOLVED]

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
petersen
Posts: 13
Joined: Mon 16 Jul 2012 08:56

discover number of active connections [SOLVED]

Post by petersen » Tue 23 Sep 2014 12:55

we need to discover the number of active connections to a database but the database has no "mon$" tables available and every client connects with the same user name.

so neither a "select * from MON$ATTACHMENTS" nor "TIBCConnection.DatabaseInfo.UserNames.Count" will work here.

we tried to make an api call on "isc_database_info()", using the handle of a "TIBCConnection" but didn't get this to work.

do you have any suggestion how to resolve this?

thanks in advance
Last edited by petersen on Wed 24 Sep 2014 14:58, edited 1 time in total.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: discover number of active connections

Post by ViktorV » Wed 24 Sep 2014 09:14

When retrieving the TIBCConnection.DatabaseInfo.UserNames property value, IBDAC uses an API function isc_database_info with a parameter isc_info_user_names. So you can use this property to retrieve the number of active connections to the database.

petersen
Posts: 13
Joined: Mon 16 Jul 2012 08:56

Re: discover number of active connections

Post by petersen » Wed 24 Sep 2014 09:33

but "TIBCConnection.DatabaseInfo.UserNames.Count" will be "1" - even if there are a lot more connections established with the same user-name (f.i. 100 connections with "SYSDBA"), right?

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: discover number of active connections

Post by ViktorV » Wed 24 Sep 2014 10:39

As we wrote above, when retrieving the TIBCConnection.DatabaseInfo.UserNames property value, IBDAC uses an API function isc_database_info with a parameter isc_info_user_names.
You can refer to the Firebird documentation to learn how this API function works.

petersen
Posts: 13
Joined: Mon 16 Jul 2012 08:56

Re: discover number of active connections

Post by petersen » Wed 24 Sep 2014 13:06

looks like we have this problem (multiple connections active but only a single entry for a username) with ibdac under xe5?!

SELECT COUNT(*) FROM MON$ATTACHMENTS WHERE MON$USER = 'SYSDBA';
-> 3

TIBCConnection.DatabaseInfo.UserNames.CommaText
-> SYSDBA,SYSDBA,SYSDBA (XE, IBDAC 4.6.12)
-> SYSDBA,SYSDBA,SYSDBA (XE, IBDAC 5.4.10)
but
-> SYSDBA (XE5, IBDAC 5.3.9)
-> SYSDBA (XE5, IBDAC 5.4.10)

any suggestions?

petersen
Posts: 13
Joined: Mon 16 Jul 2012 08:56

Re: discover number of active connections

Post by petersen » Wed 24 Sep 2014 14:58

we finaly found the problem:

on the xe5 machine we installed the firebird-server with the "-classic -multithreaded" switches! after changing to "-superserver", "TIBCConnection.DatabaseInfo.UserNames.Count" shows the correct number of connections

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: discover number of active connections [SOLVED]

Post by ViktorV » Thu 25 Sep 2014 05:28

It is good to see that the problem has been solved. If any questions concerning our products come up, please contact us.

Post Reply