Subject | Re: [Firebird-Java] Re: Active connected users |
---|---|
Author | Roman Rokytskyy |
Post date | 2007-01-15T22:41:52Z |
>> is there any way to get a list of all currently connected users?Here's the code to obtain a list of currently connected user to a
specific database (assumes you have already open connection):
AbstractConnection abstractConnection =
(AbstractConnection)connection;
GDS gds = (abstractConnection).getInternalAPIHandler();
byte[] infoRequest = new byte[] {
ISCConstants.isc_info_user_names, ISCConstants.isc_info_end};
byte[] reply = gds.iscDatabaseInfo(
abstractConnection.getIscDBHandle(), infoRequest, 1024);
int i = 0;
while(reply[i] != ISCConstants.isc_info_end) {
switch(reply[i++]) {
case ISCConstants.isc_info_user_names :
int len = gds.iscVaxInteger(reply, i, 2); // can be ignored
i += 2;
int strLen = reply[i] & 0xff;
i += 1;
String userName = new String(reply, i, strLen);
i += strLen;
System.out.println(userName); // replace with your code
break;
default :
break;
}
}
>> And how can i drop/kill an active hanging connection?No programming method available. The only possibility is to track the
socket connection and close it (on Windows you can use tcpview.exe).
Roman