public static void insertMovieReviewsReply(int memberId, int review_id, String review) { ResultSet rs; int movie_id = 0; String str2 = "insert into reviewreply values (" + review_id + ", " + memberId + ", '" + review + "', 0)"; // update reviewreply table DBConnections.query = str2; int ret = DBConnections.openDbConnectionForUpdate(DBConnections.query); DBConnections.closeDbConnection(); if (ret == 1) System.out.println("Your reply has been updated!!!"); // find status, credit_points and member_points String memberShipStatus = null; int credit_points = 0; int member_points = 0; String str4 = "select status, credit_points, member_points from membership where member_id = " + memberId; DBConnections.query = str4; rs = DBConnections.openDbConnectionForSelect(DBConnections.query); try { while (rs.next()) { memberShipStatus = rs.getString(1); credit_points = rs.getInt(2); member_points = rs.getInt(3); } } catch (SQLException e) { e.printStackTrace(); } finally { DBConnections.closeDbConnection(); } // give points on posting a review int points = 0; if (memberShipStatus.equals("Silver")) points = 5; if (memberShipStatus.equals("Gold")) points = 10; if (memberShipStatus.equals("Platinum")) points = 20; String str5 = "update membership set credit_points = " + (credit_points + points) + ", member_points = " + (member_points + points) + " where member_id = " + memberId; DBConnections.query = str5; ret = DBConnections.openDbConnectionForUpdate(DBConnections.query); DBConnections.closeDbConnection(); }
public static void likeComment(int review_id) { ResultSet rs; int like_count = 0; String str1 = "select like_count from review where review_id = " + review_id; DBConnections.query = str1; rs = DBConnections.openDbConnectionForSelect(DBConnections.query); try { while (rs.next()) { like_count = rs.getInt(1); } } catch (SQLException e) { e.printStackTrace(); } finally { DBConnections.closeDbConnection(); } String str = "update review set like_count = " + (like_count + 1) + " where review_id = " + review_id; DBConnections.query = str; int ret = DBConnections.openDbConnectionForUpdate(DBConnections.query); if (ret == 1) System.out.println("Thank you for liking the comment."); DBConnections.closeDbConnection(); }
public static void updateTable(String query) { ResultSet rs1; DBConnections.query = query; int ret = DBConnections.openDbConnectionForUpdate(DBConnections.query); DBConnections.closeDbConnection(); if (ret == 1) { System.out.println("Query executed Successfully\n"); } }
public static void updateProfile(int memberId, int option, String value) { String str1 = "update userregistration set phone = '" + value + "' where member_id = " + memberId; String str2 = "update userregistration set address = '" + value + "' where member_id = " + memberId; if (option == 1) DBConnections.query = str1; if (option == 2) DBConnections.query = str2; int ret = DBConnections.openDbConnectionForUpdate(DBConnections.query); DBConnections.closeDbConnection(); if (ret == 1) { System.out.println("\nProfile updated\n"); System.out.println("\nYour Account details :"); viewProfile(memberId); } }
public static void updatePolicy(String membership_status, String policy_type, float value) { ResultSet rs; String str = "update policies set " + policy_type + " = '" + value + "' where membership_status = '" + membership_status + "'"; DBConnections.query = str; int ret = DBConnections.openDbConnectionForUpdate(DBConnections.query); DBConnections.closeDbConnection(); if (ret == 1) { System.out.println("Policy update\n"); DBQueries.listPolicy(); } }
public static void createNewTheatreReviewThread(int memberId, String theatre, String review) { ResultSet rs; int theatre_id = 0; String str1 = "select theatre_id from theatre where name = '" + theatre + "'"; String str2 = "insert into review values (seq_review.nextVal, " + memberId + ", 0, '" + review + "', 0)"; DBConnections.query = str1; rs = DBConnections.openDbConnectionForSelect(DBConnections.query); // find movie_id try { while (rs.next()) { theatre_id = rs.getInt(1); } } catch (SQLException e) { e.printStackTrace(); } finally { DBConnections.closeDbConnection(); } // update review table DBConnections.query = str2; int ret = DBConnections.openDbConnectionForUpdate(DBConnections.query); DBConnections.closeDbConnection(); // update moviereview table String str3 = "insert into theatrereview (select " + theatre_id + ", max(review_id) from review)"; DBConnections.query = str3; DBConnections.openDbConnectionForUpdate(DBConnections.query); DBConnections.closeDbConnection(); // find status, credit_points and member_points String memberShipStatus = null; int credit_points = 0; int member_points = 0; String str4 = "select status, credit_points, member_points from membership where member_id = " + memberId; DBConnections.query = str4; rs = DBConnections.openDbConnectionForSelect(DBConnections.query); try { while (rs.next()) { memberShipStatus = rs.getString(1); credit_points = rs.getInt(2); member_points = rs.getInt(3); } } catch (SQLException e) { e.printStackTrace(); } finally { DBConnections.closeDbConnection(); } // give points on posting a review int points = 0; if (memberShipStatus.equals("Silver")) points = 5; if (memberShipStatus.equals("Gold")) points = 10; if (memberShipStatus.equals("Platinum")) points = 20; String str5 = "update membership set credit_points = " + (credit_points + points) + ", member_points = " + (member_points + points) + " where member_id = " + memberId; DBConnections.query = str5; ret = DBConnections.openDbConnectionForUpdate(DBConnections.query); DBConnections.closeDbConnection(); System.out.println("Review thread created\n"); }