Commit 59724f99 authored by kcchik's avatar kcchik
Browse files
parents 3838960a 229b136a
......@@ -152,10 +152,10 @@ public class ClientApplication {
}
public static void addReview(String entity) {
String searchMovieQueryPrefix = "select * from Movies where title like ";
String searchMovieQueryString = "select * from Movies where title like '%s%%'";
try {
Statement st = c.createStatement();
String query = searchMovieQueryPrefix + "'" + entity + "%'";
String query = String.format(searchMovieQueryString, entity);
ResultSet rs = st.executeQuery(query);
if (rs.next()) {
......@@ -164,7 +164,7 @@ public class ClientApplication {
query = String.format("select * from Reviews where movieID = '%s' and userID = '%s'", movieID, User);
rs = st.executeQuery(query);
if (rs.next()) {
System.out.println("You have already added a review for this movie.");
System.out.println("You have already added a review for " + movieTitle + ".");
} else {
// Give user option to add review to movie
......@@ -187,10 +187,10 @@ public class ClientApplication {
}
public static void editReview(String entity) {
String searchMovieQueryPrefix = "select * from Movies where title like ";
String searchMovieQueryString = "select * from Movies where title like '%s%%'";
try {
Statement st = c.createStatement();
String query = searchMovieQueryPrefix + "'" + entity + "%'";
String query = String.format(searchMovieQueryString, entity);
ResultSet rs = st.executeQuery(query);
if (rs.next()) {
......@@ -221,20 +221,22 @@ public class ClientApplication {
}
public static void deleteReview(String entity) {
String searchMovieQueryPrefix = "select * from Movies where title like ";
String searchMovieQueryString = "select * from Movies where title like '%s%%'";
try {
Statement st = c.createStatement();
String query = searchMovieQueryPrefix + "'" + entity + "%'";
String query = String.format(searchMovieQueryString, entity);
ResultSet rs = st.executeQuery(query);
if (rs.next()) {
System.out.println("Are you sure you want to delete this review? Type y to confirm. Type any other character to cancel.");
String movieID = rs.getString(1);
String movieTitle = rs.getString(2);
System.out.println("Are you sure you want to delete your review for " + movieTitle + "?");
System.out.println("Type y to confirm. Type any other character to cancel.");
String command = "";
command = input.nextLine();
if (command.equals("y")) {
String movieID = rs.getString(1);
query = String.format("select * from Reviews where movieID = '%s' and userID = '%s'", movieID, User);
rs = st.executeQuery(query);
if (!rs.next()) {
......
......@@ -69,16 +69,16 @@ from ImdbMovies;
-- person stuff
create table People (
personID char(9) not null,
firstName varchar(64),
lastName varchar(256),
name varchar(64),
birthName varchar(256),
height int,
bio text,
birthDetails varchar(256),
dateOfBirth datetime
);
alter table People add primary key (personID);
replace into People (personID, firstName, lastName, height, bio, birthDetails, dateOfBirth)
select personID, firstName, lastName, height, bio, birthDetails, dateOfBirth from ImdbNames;
replace into People (personID, name, birthName, height, bio, birthDetails, dateOfBirth)
select personID, name, birthName, height, bio, birthDetails, dateOfBirth from ImdbNames;
create table DeadPeople (
personID char(9) not null,
......
......@@ -36,8 +36,8 @@ update ImdbMovies set grossIncomeWorldwide = '$ 0' where grossIncomeWorldwide =
drop table if exists ImdbNames;
create table ImdbNames (
personID char(9),
firstName varchar(64),
lastName varchar(256),
name varchar(64),
birthName varchar(256),
height int,
bio text,
birthDetails varchar(256),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment