@Override public List<Session> listSessions() throws SQLException {
  String sql="show processlist";
  Statement stmt=null;
  ResultSet rs=null;
  LinkedList<Session> sessions=new LinkedList<Session>();
  try {
    stmt=dbConn.createStatement();
    rs=stmt.executeQuery(sql);
    while (rs.next()) {
      Session session=new Session();
      session.setIdentifier(rs.getString("Id"));
      session.setLogin(rs.getString("User"));
      sessions.add(session);
    }
  }
  finally {
    if (rs != null)     rs.close();
    if (stmt != null)     stmt.close();
  }
  return sessions;
}

@ Override public List < Session > listSessions ( ) throws SQLException { String sql = "show processlist" ; Statement stmt = null ; ResultSet rs = null ; LinkedList < Session > sessions = new LinkedList < Session > ( ) ; try { stmt = dbConn . createStatement ( ) ; rs = stmt . executeQuery ( sql ) ; while ( rs . next ( ) ) { Session session = new Session ( ) ; session . setIdentifier ( rs . getString ( "Id" ) ) ; session . setLogin ( rs . getString ( "User" ) ) ; sessions . add ( session ) ; } } finally { if ( rs != null ) rs . close ( ) ; if ( stmt != null ) stmt . close ( ) ; } return sessions ; }
issue show processlist command to get a list of all currently available sessions .
