forked from halnigalni/DB_Team3_Phase4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshowepisode.jsp
81 lines (73 loc) · 2.19 KB
/
showepisode.jsp
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page language = "java" import ="java.text.*, java.sql.*,java.util.ArrayList"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>에피소드 보기</title>
</head>
<body>
<%
String serverIP = "localhost";
String strSID = "orcl";
String portNum = "1521";
String user = "university";
String pass = "comp322";
String url = "jdbc:oracle:thin:@"+serverIP+":"+portNum+":"+strSID;
String username = "";
Connection conn = null; // Connection object
Statement stmt = null; // Statement object
ResultSet rs;
ArrayList<Integer> Season_number = new ArrayList<>();
ArrayList<Integer> Episode_number = new ArrayList<>();
ArrayList<String> Episode_title = new ArrayList<>();
ArrayList<Integer> id = new ArrayList<>();
String title="";
Class.forName("oracle.jdbc.driver.OracleDriver");
conn=DriverManager.getConnection(url,user,pass);
String sql ="";
String title_id = (String)session.getAttribute("title_id");
try {
conn.setAutoCommit(false);
stmt = conn.createStatement();
sql = "SELECT title FROM MOVIE WHERE title_id = "+title_id;
rs = stmt.executeQuery(sql);
while(rs.next())
{
title = rs.getString(1);
}
rs.close();
}catch(SQLException ex)
{
System.err.println("sql error = "+ex.getMessage());
System.exit(1);
}
out.println("<h4> << "+title+"의 에피소드 목록 >> </h4>");
//title_id에 따른 title불러오기
try {
conn.setAutoCommit(false);
stmt = conn.createStatement();
sql = "SELECT Season_number, Episode_number, Episode_title FROM EPISODE WHERE Parent_id = "+title_id;
rs = stmt.executeQuery(sql);
while(rs.next())
{
Season_number.add(rs.getInt(1));
Episode_number.add(rs.getInt(2));
Episode_title.add(rs.getString(3));
}
rs.close();
}catch(SQLException ex)
{
System.err.println("sql error = "+ex.getMessage());
System.exit(1);
}
//title_id 에 따른 episode 불러오기
int cnt = Season_number.size();
for(int i=0;i<cnt;i++)
{
out.println("<br> "+"Season"+Season_number.get(i)+"-"+Episode_number.get(i)+" : "+Episode_title.get(i));
}
%>
</body>
</html>