-
Notifications
You must be signed in to change notification settings - Fork 1
/
addepisode.jsp
90 lines (82 loc) · 2.64 KB
/
addepisode.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
82
83
84
85
86
87
88
89
90
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page language = "java" import ="java.text.*, java.sql.*"%>
<%@ page language = "java" import = "java.util.ArrayList,javax.swing.JButton,javax.swing.ButtonGroup " %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>에피소드 등록</title>
</head>
<body>
<form action = "addingepisode.jsp" method = "POST">
<%
String title_id = (String)session.getAttribute("title_id");
String manager_id = (String)session.getAttribute("manager_id");
String serverIP = "localhost";
String strSID = "orcl";
String portNum = "1521";
String user = "university";
String pass = "comp322";
String url = "jdbc:oracle:thin:@"+serverIP+":"+portNum+":"+strSID;
String sql="";
Connection conn = null; // Connection object
Statement stmt = null; // Statement object
ResultSet rs;
Class.forName("oracle.jdbc.driver.OracleDriver");
conn=DriverManager.getConnection(url,user,pass);
String title="";
ArrayList<Integer> Season_number = new ArrayList<>();
ArrayList<Integer> Episode_number = new ArrayList<>();
ArrayList<String> Episode_title = new ArrayList<>();
ArrayList<Integer> id = new ArrayList<>();
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("<h2> :: "+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));
}
session.setAttribute("title_id", title_id);
session.setAttribute("manager_id",manager_id);
%>
<br><br>
Season number : <input type ="text" name = "snum"><br>
Episode number : <input type = "text" name = "epnum"><br>
Episode Title : <input type = "text" name = "eptitle"><br>
<input type = "submit" value = "에피소드 추가">
</form>
</body>
</html>