Subject Limiting / Regulating Database Connections
Author msimmons15
I'm using a table containing information for each logged on user to
regulate the number of licensed users allowed for our product. Based
on a timer in the application, the usage record is updated
periodically to show the user is still active (and the app didn't
abort due to a bug or lost connection). If the timespan in the
usage record exceeds a certain duration, I know the user is no
longer connected, the record can be deleted and a seat opened up for
another user. Also, a user logging off normally deletes this usage
record. Since the app uses a single Firebird user ID for all client
application accesses, I cannot use the Firebird list of connected
users.

This has worked OK in the past, but there are a couple of problems..

1. The usage record is not immediately eliminated after an app
abend. Sometimes a user has to wait to logon.
2. I now want to implement a logoff strategy if a user has had no
activity for a period of time. I'm using FIBDatabase component which
can be used to log off the user, but the update of the usage record
periodically fools the component into thinking there is activity.

I could use a 2nd database connection to perform the periodic
updates of the usage record, but I shy away from this due to Windows
limits on network connections.

So, I'm wondering if the database connection information can be
used. I'm aware that the "CURRENT_CONNECTION" is available for use,
but is there any way to determine if another connection is still
running?

Is there any way to post an event if a connection is closed?

Has anyone seen a better approach for regulating connections?

Thanks,
Mike Simmons