From 0791a775ee3be8ec6951f7c26a9e90f81181d481 Mon Sep 17 00:00:00 2001 From: mouse4432 Date: Tue, 21 Nov 2023 21:40:45 +0900 Subject: [PATCH] lab 9 works --- KNU_MUSEUM/.classpath | 7 +- KNU_MUSEUM/src/main/webapp/NewFile.jsp | 13 --- KNU_MUSEUM/src/main/webapp/response.jsp | 147 ++++++++++++++++++++++++ KNU_MUSEUM/src/main/webapp/view.html | 65 +++++++++++ 4 files changed, 218 insertions(+), 14 deletions(-) delete mode 100644 KNU_MUSEUM/src/main/webapp/NewFile.jsp create mode 100644 KNU_MUSEUM/src/main/webapp/response.jsp create mode 100644 KNU_MUSEUM/src/main/webapp/view.html diff --git a/KNU_MUSEUM/.classpath b/KNU_MUSEUM/.classpath index 75dd1bc..136347e 100644 --- a/KNU_MUSEUM/.classpath +++ b/KNU_MUSEUM/.classpath @@ -1,6 +1,10 @@ - + + + + + @@ -9,5 +13,6 @@ + diff --git a/KNU_MUSEUM/src/main/webapp/NewFile.jsp b/KNU_MUSEUM/src/main/webapp/NewFile.jsp deleted file mode 100644 index c372dd9..0000000 --- a/KNU_MUSEUM/src/main/webapp/NewFile.jsp +++ /dev/null @@ -1,13 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=UTF-8" - pageEncoding="UTF-8"%> - - - - -Insert title here - - -Hello World! Team 9 -hi hello - - \ No newline at end of file diff --git a/KNU_MUSEUM/src/main/webapp/response.jsp b/KNU_MUSEUM/src/main/webapp/response.jsp new file mode 100644 index 0000000..3f984ec --- /dev/null +++ b/KNU_MUSEUM/src/main/webapp/response.jsp @@ -0,0 +1,147 @@ +<%@ page language="java" contentType="text/html; charset=EUC-KR" + pageEncoding="EUC-KR"%> +<%@ page language="java" import="java.text.*,java.sql.*" %> + + + + +COMP322: Introduction to Databases + + +<% + String serverIP = "localhost"; + String strSID = "orcl"; + String portNum = "1521"; + String user = "Company"; + String pass = "comp322"; + String url = "jdbc:oracle:thin:@"+serverIP+":"+portNum+":"+strSID; + String query = new String(); + Connection conn = null; + PreparedStatement pstmt; + ResultSet rs; + Class.forName("oracle.jdbc.driver.OracleDriver"); + conn = DriverManager.getConnection(url,user,pass); +%> + +

Lab #9: Repeating Lab #5-3 via JSP

+

------ Q1 Result --------

+ +<% +//Q1 + query = "Select E.Fname, E.Lname, E.Salary from Employee E, Project P, Works_on W" + + " Where P.Pnumber = W.Pno and W.Essn = E.Ssn and P.Pname LIKE '"+ request.getParameter("Project1") + + "' and E.Dno = " + request.getParameter("Dnum") + " and E.Salary >= " + request.getParameter("Salary"); + pstmt = conn.prepareStatement(query); + rs = pstmt.executeQuery(); + out.println(""); + ResultSetMetaData rsmd = rs.getMetaData(); + int cnt = rsmd.getColumnCount(); + for(int i =1;i<=cnt;i++){ + out.println(""); + } + while(rs.next()){ + out.println(""); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + } + out.println("
"+rsmd.getColumnName(i)+"
" + rs.getString(1) + "" + rs.getString(2) + "" + rs.getFloat(3) + "
"); +%> +

------ Q2 Result --------

+<% +//Q2 + query = "Select D.Dname, E.Ssn, E.Fname, E.Lname from Employee E, Department D " + + "Where E.Dno = D.Dnumber and E.Super_ssn = '" + request.getParameter("SSN1") +"' and E.Address LIKE '%" + request.getParameter("address") +"%'"; + pstmt = conn.prepareStatement(query); + rs = pstmt.executeQuery(); + out.println(""); + rsmd = rs.getMetaData(); + cnt = rsmd.getColumnCount(); + for(int i =1;i<=cnt;i++){ + out.println(""); + } + while(rs.next()){ + out.println(""); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + } + out.println("
"+rsmd.getColumnName(i)+"
" + rs.getString(1) + "" + rs.getString(2) + "" + rs.getString(3) + "" + rs.getString(4) + "
"); +%> +

------ Q3 Result --------

+<% +//Q3 + query = "Select E.Fname, E.Lname, W.Hours from Employee E, Project P, Works_on W " + + "Where E.Ssn = W.Essn and P.Pnumber = W.Pno and P.Pname = '" + request.getParameter("Project3") +"' and W.Hours >=" + request.getParameter("hour3"); + pstmt = conn.prepareStatement(query); + rs = pstmt.executeQuery(); + out.println(""); + rsmd = rs.getMetaData(); + cnt = rsmd.getColumnCount(); + for(int i =1;i<=cnt;i++){ + out.println(""); + } + while(rs.next()){ + out.println(""); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + } + out.println("
"+rsmd.getColumnName(i)+"
" + rs.getString(1) + "" + rs.getString(2) + "" + rs.getInt(3) + "
"); +%> +

------ Q4 Result --------

+<% +//Q4 + query = "Select DISTINCT D.Dname, E.Fname, E.Lname from Employee E, Project P, Works_on W, Department D " + + "Where E.Ssn = W.Essn and P.Pnumber = W.Pno and P.Dnum = D.Dnumber and P.Pname LIKE '%" + request.getParameter("Project4") +"%' and W.Hours >=" + request.getParameter("hour4"); + pstmt = conn.prepareStatement(query); + rs = pstmt.executeQuery(); + out.println(""); + rsmd = rs.getMetaData(); + cnt = rsmd.getColumnCount(); + for(int i =1;i<=cnt;i++){ + out.println(""); + } + while(rs.next()){ + out.println(""); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + } + out.println("
"+rsmd.getColumnName(i)+"
" + rs.getString(1) + "" + rs.getString(2) + "" + rs.getString(3) + "
"); +%> +

------ Q5 Result --------

+<% +//Q5 + query = "Select D.Dname, E.Lname, E.Fname, DE.Dependent_name from Dependent DE, Employee E, Department D " + + "Where E.Dno = D.Dnumber and E.Ssn = DE.Essn and DE.Relationship = 'Spouse' and E.Super_ssn = " + request.getParameter("SSN5"); + pstmt = conn.prepareStatement(query); + rs = pstmt.executeQuery(); + out.println(""); + rsmd = rs.getMetaData(); + cnt = rsmd.getColumnCount(); + for(int i =1;i<=cnt;i++){ + out.println(""); + } + while(rs.next()){ + out.println(""); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + } + out.println("
"+rsmd.getColumnName(i)+"
" + rs.getString(1) + "" + rs.getString(2) + "" + rs.getString(3) + "" + rs.getString(4) + "
"); +%> +<% + rs.close(); + pstmt.close(); + conn.close(); +%> + + \ No newline at end of file diff --git a/KNU_MUSEUM/src/main/webapp/view.html b/KNU_MUSEUM/src/main/webapp/view.html new file mode 100644 index 0000000..049921c --- /dev/null +++ b/KNU_MUSEUM/src/main/webapp/view.html @@ -0,0 +1,65 @@ + + + + +COMP322: Introduction to Databases + + +

Lab #9: Repeating #5-3 vis JSP

+ +
+

Query 1: Search for employees satisfying the following conditions:

+ Project name starting with: + + Department number: + + Salary greater than or equal to: + +

+

Query 2: Search for employees satisfying the following conditions:

+ Supervisor's SSN: + + Address including: + +

+

Query 3: Search for employees working on:

+ Project name: + + Working hours more than: + +

+

Query 4: Search for employees working on:

+ Project name starting with: + +
+ Working hours greater than or equal to: + +

+

Query 5: Search for a supervisee(s) and his/her spouse(s) with:

+ Supervisor's SSN: + +

+ + +
+ + + \ No newline at end of file