shell
mysql -h 192.168.0.136 -P 3306 -N -u root -p'abcd' -e 'show full processlist' | egrep -v 'Sleep|show full processlist'
jsp
String sql = " show full processlist ";
rs = stmt.executeQuery(sql);
while (rs.next()) {
String id = rs.getString("Id");
String user = rs.getString("User");
String host = rs.getString("Host");
String db = rs.getString("db");
String command = rs.getString("Command");
String info = rs.getString("Info");
String state = rs.getString("State");
if (command.equalsIgnoreCase("Sleep")) continue;
if (info.equalsIgnoreCase("show full processlist")) continue;
if (info.length()==0 && state.length()==0) continue;
int time = rs.getInt("Time");
// print
}