In Java also need the SQL provided Objective : Create a Movie Rating System (MRS
ID: 3716568 • Letter: I
Question
In Java also need the SQL provided
Objective: Create a Movie Rating System (MRS). The MRS will contain a catalog of movies that can be managed, viewed, and rated.
Components detail:
The Movie Rating System (MRS) has two main components a) the movie catalog management component; b) movie catalog viewing and rating component.
Movie Catalog Management Component
The movie catalog management component should avail an admin user with the following functionalities:
Ability to view, add, update, and delete movies from the catalog.
As part of the update admin should not have the ability to update any of the rating related information of a movie. Update should allow other attributes such as, the movie description, title, actors, etc.
(This could be a bonus functionality) Ability to login to the system as admin role. This is the only role that would require a user to login to the system. The system would just have a predefined set of user name and password which allow them to login as an admin.
Movie Catalog Viewing and Rating Component
The movie catalog viewing and rating component allows any user (no login necessary) to perform the following:
Search and view for movies. Searching capabilities could be limit to the title of the movie.
Add rating to a movie. This includes rating scale 1 to 10 and a comment section.
(This could be another bonus functionality) Ability to select existing comment and like it. The system should display the number for likes a comment has received.
How to Calculate the Rating
Rating calculation can be as simple as average of all the rates given movie has received.
Implementation Details
Command line Menu:
Main Menu:
Admin
User
Exit
User could select an option from this list. If user select 1, it should display Admin Menu with the following options:
Admin Menu:
Add new movie
Search and update movie
Search and delete
Implements these options for admin personnel.
In main menu, if user select 2 from the Main Menu it should display user menu. User menu should contains the following options:
User Menu:
Search movie
Rate movie
Add comments
Implement these options for user activities.
Note: Make sure you implement the project by following object oriented design paradigm
Explanation / Answer
next step is to create sample table with blank fields
loading driver class into the memory and connectivity statement
this statement connects java with oracle
// Java program to illustrate
// Connecting to the Database
import java.sql.*;
public class connect
{
public static void main(String args[])
{
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
// this line is used for Establishing Connection
Connection con = DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1576:orcl", "login1", "pwd1");
if (con != null)
System.out.println("Connected");
else
System.out.println("Not Connected");
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}
now the connection wmade between the sql and java.
// Java program to illustrate
// inserting to the Database
import java.sql.*;
public class admin
{
public static void main(String args[])
{
String mv = "moviename;
String ti = "title";
String ac = "actor";
String tm = "timings";
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("
jdbc:oracle:thin:@localhost:1576:orcl", "login1", "pwd1");
Statement stmt = con.createStatement();
// Inserting data in database
String q1 = "insert into userid values('" movie names "', "title"
"', '" actor "', '" +timings+ "')";
int x = stmt.executeUpdate(q1);
if (x > 0)
System.out.println("Successfully Inserted");
else
System.out.println("Insert Failed");
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}
// Java program to illustrate
// updating the Database
import java.sql.*;
public class admin
{
public static void main(String args[])
{
String mv = "moviename;
String ti = "title";
String ac = "actor";
String tm = "timings";
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("
jdbc:oracle:thin:@localhost:1521:orcl", "login1", "pwd1");
Statement stmt = con.createStatement();
// Updating database
String q1 = "UPDATE moviename mv= '" + newmoviename +
"' WHERE id = '" +id+ "' AND mv = '" + mv + "'";
int x = stmt.executeUpdate(q1);
if (x > 0)
System.out.println("moviename Successfully Updated");
else
System.out.println("ERROR OCCURED :(");
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}
// Java program to illustrate
// selecting from Database
import java.sql.*;
public class select
{
public static void main(String args[])
{
String mv = "moviename;
String ti = "title";
String ac = "actor";
String tm = "timings";;
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("
jdbc:oracle:thin:@localhost:1576:orcl", "login1", "pwd1");
Statement stmt = con.createStatement();
// SELECT query
String q1 = "select * from mString mv = "moviename;
String ti = "title";
String ac = "actor";
String tm = "timings"; WHERE t= tm'" + id +
"' AND pwd = '" + pwd + "'";
ResultSet rs = stmt.executeQuery(q1);
if (rs.next())
{
System.out.println("moviename : " + rs.getString(1));
System.out.println("timings :" + rs.getString(3));
System.out.println("actor:" + rs.getString(4));
}
else
{
System.out.println("No such movie is already registered");
}
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}
// Java program to illustrate
// inserting to the Database
import java.sql.*;
public class admin
{
public static void main(String args[])
{
String mv = "moviename;
String ti = "title";
String ac = "actor";
String tm = "timings";
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("
jdbc:oracle:thin:@localhost:1576:orcl", "login1", "pwd1");
Statement stmt = con.createStatement();
// Inserting data in database
String q1 = "insert into userid values('" movie names "', "title"
"', '" actor "', '" +timings+ "')";
int x = stmt.executeUpdate(q1);
if (x > 0)
System.out.println("Successfully Inserted");
else
System.out.println("Insert Failed");
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}
// Java program to illustrate
// updating the Database
import java.sql.*;
public class admin
{
public static void main(String args[])
{
String mv = "moviename;
String ti = "title";
String ac = "actor";
String tm = "timings";
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("
jdbc:oracle:thin:@localhost:1521:orcl", "login1", "pwd1");
Statement stmt = con.createStatement();
// Updating database
String q1 = "UPDATE moviename mv= '" + newmoviename +
"' WHERE id = '" +id+ "' AND mv = '" + mv + "'";
int x = stmt.executeUpdate(q1);
if (x > 0)
System.out.println("moviename Successfully Updated");
else
System.out.println("ERROR OCCURED :(");
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}
// Java program to illustrate
// selecting from Database
import java.sql.*;
public class select
{
public static void main(String args[])
{
String mv = "moviename;
String ti = "title";
String ac = "actor";
String tm = "timings";;
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("
jdbc:oracle:thin:@localhost:1576:orcl", "login1", "pwd1");
Statement stmt = con.createStatement();
// SELECT query
String q1 = "select * from mString mv = "moviename;
String ti = "title";
String ac = "actor";
String tm = "timings"; WHERE t= tm'" + id +
"' AND pwd = '" + pwd + "'";
ResultSet rs = stmt.executeQuery(q1);
if (rs.next())
{
System.out.println("moviename : " + rs.getString(1));
System.out.println("timings :" + rs.getString(3));
System.out.println("actor:" + rs.getString(4));
}
else
{
System.out.println("No such movie is already registered");
}
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}
similarly user ratings should be given
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.