Here you can find the source of existsInSessionTable(String id, boolean verbose)
public static boolean existsInSessionTable(String id, boolean verbose) 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; 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 boolean existsInSessionTable(String id, boolean verbose) throws Exception { Class.forName(DRIVER_CLASS); Connection con = null;/*w ww .j ava 2s. c om*/ try { con = DriverManager.getConnection(DEFAULT_CONNECTION_URL); PreparedStatement statement = con .prepareStatement("select * from " + TABLE + " where " + ID_COL + " = ?"); statement.setString(1, id); ResultSet result = statement.executeQuery(); if (verbose) { boolean results = false; while (result.next()) { results = true; } return results; } else return result.next(); } finally { if (con != null) con.close(); } } }