(a) Given the following method header: public boolean addMovie(Movie movie) Complete the implementation of the method above to insert a new movie into the Movies table in the database. Your method should return true if an insert is successful, and false if an insert fails. You can detect a successful insert through the number of rows returned after the execution of a query. Use PreparedStatement in your answer and include the appropriate exception handling. The Movie class and database table structure specifications are shown in Figure 2.1 and Figure 2.2 below:

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

(a) Given the following method header:

public boolean addMovie(Movie movie)


Complete the implementation of the method above to insert a new movie into the Movies table in the
database. Your method should return true if an insert is successful, and false if an insert fails. You can
detect a successful insert through the number of rows returned after the execution of a query. Use
PreparedStatement in your answer and include the appropriate exception handling. The Movie class
and database table structure specifications are shown in Figure 2.1 and Figure 2.2 below:

public class Movie{
private String id;
private String name;
private String category;
private double price;
public Movie () {
}
public Movie (String id, String name, String category, double price) {
this.id = id;
this.name
name;
this.category = category;
this.price = price;
}
public String getId() {
return id;
public String getName () {
return name;
public String getCategory()
return category;
public double getPrice () {
return price;
}
Figure 2.1: Movie Class
Transcribed Image Text:public class Movie{ private String id; private String name; private String category; private double price; public Movie () { } public Movie (String id, String name, String category, double price) { this.id = id; this.name name; this.category = category; this.price = price; } public String getId() { return id; public String getName () { return name; public String getCategory() return category; public double getPrice () { return price; } Figure 2.1: Movie Class
Table Structure
Sample Data
NBUSER
Мах. гows: 100
Fetched Rows: 121 Matching Rows:
Tables
MOVIEID
MOVIENAME
CATEGORY
PRICE
MOVIES
Co01
Comedy
1
50 First Dates
25.9
MOVIEID
2
Co02
Lady Bird
Comedy
35.9
3
Co03
The Other Guys
Comedy
29.9
MOVIENAMΜΕ
4
C004
Dolemite Is My Name Comedy
30.0
CATEGORY
5
Co05
Between Two Ferns Comedy
21.5
H101
In The Tall Grass
Horror
12.9
PRICE
H102
Cargo
Horror
21.9
8.
H103
The Ritual
Horror
29.9
9
н104
Hush
Horror
28.5
10
H105
The Guest
Thriller
28.5
11
R201
The Notebook
Romance
21.9
12
R202
Eat Pray Love
Romance
21.9
Figure 2.2: Movies database table structure and sample data
Transcribed Image Text:Table Structure Sample Data NBUSER Мах. гows: 100 Fetched Rows: 121 Matching Rows: Tables MOVIEID MOVIENAME CATEGORY PRICE MOVIES Co01 Comedy 1 50 First Dates 25.9 MOVIEID 2 Co02 Lady Bird Comedy 35.9 3 Co03 The Other Guys Comedy 29.9 MOVIENAMΜΕ 4 C004 Dolemite Is My Name Comedy 30.0 CATEGORY 5 Co05 Between Two Ferns Comedy 21.5 H101 In The Tall Grass Horror 12.9 PRICE H102 Cargo Horror 21.9 8. H103 The Ritual Horror 29.9 9 н104 Hush Horror 28.5 10 H105 The Guest Thriller 28.5 11 R201 The Notebook Romance 21.9 12 R202 Eat Pray Love Romance 21.9 Figure 2.2: Movies database table structure and sample data
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 7 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY