Reputation: 4151
I want to check the number of active open connections in mysql database using java and close it.
I tried using query only
SHOW STATUS LIKE 'threads_connected';
With this can anyone tell me how to find and close the connection. I know when a database connection is established we need to close it immediately but for some other requirement i want to know active connections list and delete that list.
Any idea please suggest
Upvotes: 0
Views: 4431
Reputation: 121
I pulled aout the strings used bei HeidiSQL
First for getting a list with active connections(Processes):
SELECT ID
, USER
, HOST
, DB
, COMMAND
, TIME
, STATE
, LEFT(INFO
, 51200) AS Info
FROM information_schema
.PROCESSLIST
The for deleting a processes:
KILL {The ID of the Process};
It would probably be enough to SELECT
only the ID of the Process but with that query you get all Information needed.
Upvotes: 1