Пример #1
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;
 }
Пример #2
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;
 }