Finding and Killing Sessions in DB2 LUW (Linux / Unix / Windows)

The first step in killing a session in a DB2 LUW database is to find the session to kill. Be sure to connect to DB2 as a user that has the privileges necessary to run queries to find sessions and execute commands to kill sessions. The following query will list running sessions in a DB2 database.

SELECT APPLICATION_HANDLE, CLIENT_IPADDR, CLIENT_PORT_NUMBER, SESSION_AUTH_ID, CURRENT_SERVER, APPLICATION_NAME, CLIENT_PROTOCOL, CLIENT_PLATFORM, CLIENT_HOSTNAME, CONNECTION_START_TIME, APPLICATION_ID, EXECUTION_ID FROM TABLE(MON_GET_CONNECTION(cast(NULL as bigint), -2)) ORDER BY APPLICATION_HANDLE;

The value from the result of the above query that is needed to kill the session is the APPLICATION_HANDLE. To kill the session, execute the following command using the appropriate APPLICATION_HANDLE from the above query. In the example below, the APPLICATION_HANDLE is 774.

CALL SYSPROC.ADMIN_CMD('FORCE APPLICATION (774)');