ArrayList<Bookmark> bookmarks = new ArrayList<Bookmark>();
PreparedStatement preparedStatement = connect.prepareStatement("SELECT Id, Endpoint, Query, Title FROM Bookmarks WHERE UserId = ?");
preparedStatement.setInt(1, userId);
ResultSet result = preparedStatement.executeQuery();
while (result.next()) {
Bookmark bookmark = new Bookmark();
bookmark.setBookmarkId(result.getInt("Id"));
bookmark.setEndpoint(result.getString("Endpoint"));
bookmark.setQuery(result.getString("Query"));
bookmark.setTitle(result.getString("Title"));
bookmarks.add(bookmark);
}
result.close();
return bookmarks.toArray(new Bookmark[bookmarks.size()]);
}