예제 #1
0
 public void createMovie(Movie newMovie) {
   try {
     connection = ds.getConnection();
     statement = connection.prepareStatement(createMovie);
     statement.setObject(1, newMovie.getId());
     statement.setString(2, newMovie.getTitle());
     statement.setString(3, newMovie.getPosterImage());
     statement.setDate(4, new Date(newMovie.getReleaseDate().getTime()));
     statement.executeUpdate();
   } catch (SQLException e) {
     e.printStackTrace();
   } finally {
     try {
       connection.close();
     } catch (SQLException e) {
       e.printStackTrace();
     }
   }
 }
예제 #2
0
 public void updateMovie(Integer movieId, Movie movie) {
   try {
     connection = ds.getConnection();
     statement = connection.prepareStatement(updateMovie);
     statement.setInt(1, movie.getId());
     statement.setString(2, movie.getTitle());
     statement.setString(3, movie.getPosterImage());
     statement.setDate(4, new Date(movie.getReleaseDate().getTime()));
     statement.setInt(5, movieId);
     statement.executeUpdate();
   } catch (SQLException e) {
     e.printStackTrace();
   } finally {
     try {
       connection.close();
     } catch (SQLException e) {
       e.printStackTrace();
     }
   }
 }