Here you can find the source of getSessionIds()
public static Set<String> getSessionIds() throws Exception
//package com.java2s; // are made available under the terms of the Eclipse Public License v1.0 import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.HashSet; import java.util.Set; public class Main { public static final String DRIVER_CLASS = "org.apache.derby.jdbc.EmbeddedDriver"; public static final String DEFAULT_CONNECTION_URL = "jdbc:derby:memory:sessions;create=true"; public static final String TABLE = "mysessions"; public static final String ID_COL = "mysessionid"; public static Set<String> getSessionIds() throws Exception { HashSet<String> ids = new HashSet<String>(); Class.forName(DRIVER_CLASS); Connection con = null;//from www . j av a 2s . co m try { con = DriverManager.getConnection(DEFAULT_CONNECTION_URL); PreparedStatement statement = con.prepareStatement("select " + ID_COL + " from " + TABLE); ResultSet result = statement.executeQuery(); while (result.next()) { ids.add(result.getString(1)); } return ids; } finally { if (con != null) con.close(); } } }