public static final boolean exists(Connection connection, String table, Map<String, ?> keys) throws SQLException {
		StringBuilder s = new StringBuilder();
		s.append("SELECT CASE WHEN EXISTS(SELECT 0 FROM ");
		s.append(table);
		boolean flag = keys != null && keys.size() > 0;

		if (flag) {
			Iterator<String> iter = keys.keySet().iterator();
			s.append(" WHERE ").append(iter.next()).append("=?");
			while (iter.hasNext()) {
				s.append(" AND ").append(iter.next()).append("=?");
			}
		}
		s.append(") THEN 1 ELSE NULL END");
		PreparedStatement statement = connection.prepareStatement(s.toString());
		if (flag) {
			Iterator<?> iter = keys.values().iterator();
			statement.setObject(1, iter.next());
			int i = 2;
			while (iter.hasNext()) {
				statement.setObject(i++, iter.next());
			}
		}
		ResultSet result = statement.executeQuery();
		result.next();
		flag = result.getBoolean(1);
		Util.close(result, statement);
		return flag;
	}