Exemplo n.º 1
0
 /**
  * Return List<Game> according to page number and page size
  *
  * @param pageNumber cursor of data record
  * @param pageSize size of one page
  * @return List<Game>
  */
 public List<Game> getEntryList(int pageNumber, int pageSize) {
   List<Game> gameList = new ArrayList<Game>();
   try {
     rs = crud.fetchAll("game");
     if (rs == null) {
       return null;
     }
     if (pageNumber < 1) {
       pageNumber = 1;
     }
     if (pageNumber > 1) {
       rs.absolute(pageNumber);
     }
     for (int i = 0; i < pageSize; i++) {
       if (rs.next()) {
         Game game = new Game();
         game.setId(rs.getInt("id"));
         game.setCompany(rs.getString("company"));
         game.setName(rs.getString("name"));
         game.setSummary(rs.getString("summary"));
         game.setWebsite(rs.getString("website"));
         game.setImage(rs.getString("image"));
         game.setReleaseDate(rs.getDate("releaseDate"));
         game.setUser_id(rs.getInt("user_id"));
         gameList.add(game);
       }
     }
   } catch (SQLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return gameList;
 }
Exemplo n.º 2
0
 /**
  * @param game
  * @param rs
  * @return
  */
 private Game setGamebyResultSet(Game game, ResultSet rs) {
   try {
     if (rs.next()) {
       game.setId(rs.getInt("id"));
       game.setCompany(rs.getString("company"));
       game.setName(rs.getString("name"));
       game.setSummary(rs.getString("summary"));
       game.setReleaseDate(rs.getDate("releaseDate"));
       game.setWebsite(rs.getString("website"));
       game.setRating(rs.getInt("rating"));
       game.setUser_id(rs.getInt("user_id"));
       game.setImage(rs.getString("image"));
     } else {
       return null;
     }
   } catch (SQLException e) {
     e.printStackTrace();
     return null;
   }
   return game;
 }
Exemplo n.º 3
0
 public List<Game> getAllGame() {
   List<Game> gameList = new ArrayList<Game>();
   try {
     rs = crud.fetchAll("game");
     while (rs.next()) {
       Game game = new Game();
       game.setId(rs.getInt("id"));
       game.setCompany(rs.getString("company"));
       game.setName(rs.getString("name"));
       game.setSummary(rs.getString("summary"));
       game.setWebsite(rs.getString("website"));
       game.setImage(rs.getString("image"));
       game.setRating(rs.getInt("rating"));
       game.setReleaseDate(rs.getDate("releaseDate"));
       game.setUser_id(rs.getInt("user_id"));
       gameList.add(game);
     }
   } catch (SQLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return gameList;
 }