-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMovie.java
More file actions
40 lines (32 loc) · 1.31 KB
/
Movie.java
File metadata and controls
40 lines (32 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package Movie;
import java.sql.*;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.SQLException;
public class Movie {
public static void main(String[] args) {
try {
Class.forName("com.mysql.jdbc.Driver");
} catch(ClassNotFoundException e) {
System.out.println("Class not found "+ e);
}
try {
Connection con = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/movie","root", "root");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM movie");
System.out.println("MovieName Actor Actress Director YearofRelease");
while (rs.next()) {
String MovieName = rs.getString("MovieName");
String Actor = rs.getString("Actor");
String Actress = rs.getString("Actress");
String Director = rs.getString("Director");
int YearofRelease = rs.getInt("YearofRelease");
System.out.println(MovieName+" "+Actor+" "+Actress+" "+Director+" "+YearofRelease);
}
} catch(SQLException e) {
System.out.println("SQL exception occured" + e);
}
}
}