From bca76d88a62f17a177a193a8e6ab0b2ad91a9098 Mon Sep 17 00:00:00 2001 From: FJY Date: Wed, 1 Nov 2017 23:02:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=80=E6=9C=89=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E6=80=A7=E8=83=BD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebRoot/JSPhandle/admin_delete.jsp | 4 + WebRoot/JSPhandle/admin_insert.jsp | 4 + WebRoot/JSPhandle/admin_update.jsp | 4 + WebRoot/JSPhandle/adminjob_delete.jsp | 4 + WebRoot/JSPhandle/adminjob_insert.jsp | 4 + WebRoot/JSPhandle/change_pass_update.jsp | 6 +- WebRoot/JSPhandle/forget_pass_check.jsp | 18 ++- WebRoot/JSPhandle/job_delete.jsp | 4 + WebRoot/JSPhandle/limits_check_delete.jsp | 11 +- WebRoot/JSPhandle/limits_check_manage.jsp | 12 +- WebRoot/JSPhandle/limits_check_show.jsp | 11 +- WebRoot/JSPhandle/login.jsp | 1 + WebRoot/JSPhandle/login_show.jsp | 140 +++++++++---------- WebRoot/JSPhandle/signin_insert.jsp | 6 +- WebRoot/JSPhandle/user_delete.jsp | 4 + WebRoot/JSPhandle/user_update.jsp | 4 + WebRoot/JSPhandle/vipdownload_check_show.jsp | 11 +- WebRoot/add_admin.jsp | 13 +- WebRoot/change_admin.jsp | 12 +- WebRoot/change_user.jsp | 13 +- WebRoot/delete_admin.jsp | 12 +- WebRoot/delete_job.jsp | 13 +- WebRoot/delete_user.jsp | 13 +- WebRoot/edit_admin.jsp | 24 ++-- WebRoot/edit_user.jsp | 17 ++- WebRoot/exhibition_admin.jsp | 13 +- WebRoot/manage_user.jsp | 13 +- WebRoot/show_admin.jsp | 29 ++-- WebRoot/show_adminjob.jsp | 13 +- WebRoot/show_user.jsp | 13 +- WebRoot/x2_resource.jsp | 13 +- 31 files changed, 288 insertions(+), 171 deletions(-) diff --git a/WebRoot/JSPhandle/admin_delete.jsp b/WebRoot/JSPhandle/admin_delete.jsp index f28d516..0dc6f43 100644 --- a/WebRoot/JSPhandle/admin_delete.jsp +++ b/WebRoot/JSPhandle/admin_delete.jsp @@ -37,6 +37,7 @@ String use = "root"; String password = ""; Class.forName(driver); + try{ Connection conn = DriverManager.getConnection(url, use, password); PreparedStatement sql = conn .prepareStatement("delete from adminstrator_record where AdminName=?"); @@ -47,6 +48,9 @@ } sql.close(); conn.close(); + }catch (Exception ex) { + ex.printStackTrace(); + } %> <% diff --git a/WebRoot/JSPhandle/admin_insert.jsp b/WebRoot/JSPhandle/admin_insert.jsp index 1ae4514..243b499 100644 --- a/WebRoot/JSPhandle/admin_insert.jsp +++ b/WebRoot/JSPhandle/admin_insert.jsp @@ -39,6 +39,7 @@ String use = "root"; String password = ""; Class.forName(driver); + try{ Connection conn = DriverManager.getConnection(url, use, password); PreparedStatement sql = conn .prepareStatement("insert into adminstrator_record(AdminNo,AdminName,Adminsex,Adminjob)values(?,?,?,?)"); @@ -52,6 +53,9 @@ } sql.close(); conn.close(); + }catch (Exception ex) { + ex.printStackTrace(); + } %> <% diff --git a/WebRoot/JSPhandle/admin_update.jsp b/WebRoot/JSPhandle/admin_update.jsp index afa8ddf..8a150be 100644 --- a/WebRoot/JSPhandle/admin_update.jsp +++ b/WebRoot/JSPhandle/admin_update.jsp @@ -39,6 +39,7 @@ String use = "root"; String password = ""; Class.forName(driver); + try{ Connection conn = DriverManager.getConnection(url, use, password); PreparedStatement sql = conn .prepareStatement("update adminstrator_record set AdminNo=?,AdminSex=?,AdminJob=? where AdminName=?"); @@ -52,6 +53,9 @@ } sql.close(); conn.close(); + }catch (Exception ex) { + ex.printStackTrace(); + } %> <% diff --git a/WebRoot/JSPhandle/adminjob_delete.jsp b/WebRoot/JSPhandle/adminjob_delete.jsp index 9a09bc5..3860ac9 100644 --- a/WebRoot/JSPhandle/adminjob_delete.jsp +++ b/WebRoot/JSPhandle/adminjob_delete.jsp @@ -37,6 +37,7 @@ String use = "root"; String password = ""; Class.forName(driver); + try{ Connection conn = DriverManager.getConnection(url, use, password); PreparedStatement sql = conn .prepareStatement("delete from administrator_job where AdminJob=?"); @@ -47,6 +48,9 @@ } sql.close(); conn.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } %> <% diff --git a/WebRoot/JSPhandle/adminjob_insert.jsp b/WebRoot/JSPhandle/adminjob_insert.jsp index 3f0c4d8..2707682 100644 --- a/WebRoot/JSPhandle/adminjob_insert.jsp +++ b/WebRoot/JSPhandle/adminjob_insert.jsp @@ -37,6 +37,7 @@ String use = "root"; String password = ""; Class.forName(driver); + try{ Connection conn = DriverManager.getConnection(url, use, password); PreparedStatement sql = conn .prepareStatement("insert into administrator_job(AdminJob,AdminDuty)values(?,?)"); @@ -48,6 +49,9 @@ } sql.close(); conn.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } %> <% diff --git a/WebRoot/JSPhandle/change_pass_update.jsp b/WebRoot/JSPhandle/change_pass_update.jsp index 6a46bf6..e9a6554 100644 --- a/WebRoot/JSPhandle/change_pass_update.jsp +++ b/WebRoot/JSPhandle/change_pass_update.jsp @@ -33,7 +33,8 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request. String url="jdbc:mysql://localhost:3306/db_school?useUnicode=true&characterEncoding=utf-8"; String use = "root"; String password = ""; - Class.forName(driver); + Class.forName(driver); + try{ Connection conn= DriverManager.getConnection(url,use,password); PreparedStatement sql =conn.prepareStatement("update user set password=? where userName=?"); sql.setString(1,pass); @@ -41,6 +42,9 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request. int rtn=sql.executeUpdate(); sql.close(); conn.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } %> <% out.println(""); diff --git a/WebRoot/JSPhandle/forget_pass_check.jsp b/WebRoot/JSPhandle/forget_pass_check.jsp index a3f66a9..78c5f10 100644 --- a/WebRoot/JSPhandle/forget_pass_check.jsp +++ b/WebRoot/JSPhandle/forget_pass_check.jsp @@ -26,9 +26,7 @@ String pass = request.getParameter("inputPassword"); String phone = request.getParameter("PhoneNumber"); boolean flag = false; - PreparedStatement sql = null; - ResultSet rs = null; - Connection conn = null; + %> @@ -38,6 +36,10 @@ String use = "root"; String password = ""; Class.forName(driver); + try{ + PreparedStatement sql = null; + ResultSet rs = null; + Connection conn = null; conn = DriverManager.getConnection(url, use, password); sql = conn.prepareStatement("select * from user where userName=? and Email=? and phoneNum=?"); sql.setString(1, users); @@ -47,6 +49,12 @@ if (rs.next()) { flag = true; } + rs.close(); + sql.close(); + conn.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } %> <% @@ -58,9 +66,7 @@ } else if (flag == false) { out.println(""); } - rs.close(); - sql.close(); - conn.close(); + %> diff --git a/WebRoot/JSPhandle/job_delete.jsp b/WebRoot/JSPhandle/job_delete.jsp index 9a09bc5..3860ac9 100644 --- a/WebRoot/JSPhandle/job_delete.jsp +++ b/WebRoot/JSPhandle/job_delete.jsp @@ -37,6 +37,7 @@ String use = "root"; String password = ""; Class.forName(driver); + try{ Connection conn = DriverManager.getConnection(url, use, password); PreparedStatement sql = conn .prepareStatement("delete from administrator_job where AdminJob=?"); @@ -47,6 +48,9 @@ } sql.close(); conn.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } %> <% diff --git a/WebRoot/JSPhandle/limits_check_delete.jsp b/WebRoot/JSPhandle/limits_check_delete.jsp index 2539a6e..1867ad7 100644 --- a/WebRoot/JSPhandle/limits_check_delete.jsp +++ b/WebRoot/JSPhandle/limits_check_delete.jsp @@ -23,9 +23,7 @@ <% request.setCharacterEncoding("utf-8"); boolean flag = false; - PreparedStatement sql = null; - ResultSet rs = null; - Connection conn = null; + if (session.getAttribute("actualuser") == null) { out.println( ""); @@ -41,6 +39,10 @@ String use = "root"; String password = ""; Class.forName(driver); + try{ + PreparedStatement sql = null; + ResultSet rs = null; + Connection conn = null; conn = DriverManager.getConnection(url, use, password); sql = conn.prepareStatement("select * from show_user where userName=? and Administrator=1"); sql.setString(1, users); @@ -51,6 +53,9 @@ rs.close(); sql.close(); conn.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } %> <% diff --git a/WebRoot/JSPhandle/limits_check_manage.jsp b/WebRoot/JSPhandle/limits_check_manage.jsp index b4307b4..2fde9dd 100644 --- a/WebRoot/JSPhandle/limits_check_manage.jsp +++ b/WebRoot/JSPhandle/limits_check_manage.jsp @@ -23,9 +23,7 @@ <% request.setCharacterEncoding("utf-8"); boolean flag = false; - PreparedStatement sql = null; - ResultSet rs = null; - Connection conn = null; + if (session.getAttribute("actualuser") == null) { out.println( ""); @@ -41,6 +39,10 @@ String use = "root"; String password = ""; Class.forName(driver); + try{ + PreparedStatement sql = null; + ResultSet rs = null; + Connection conn = null; conn = DriverManager.getConnection(url, use, password); sql = conn.prepareStatement("select * from show_user where userName=? and Administrator=1"); sql.setString(1, users); @@ -51,6 +53,10 @@ rs.close(); sql.close(); conn.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + %> <% diff --git a/WebRoot/JSPhandle/limits_check_show.jsp b/WebRoot/JSPhandle/limits_check_show.jsp index 35fda7f..b8b06ba 100644 --- a/WebRoot/JSPhandle/limits_check_show.jsp +++ b/WebRoot/JSPhandle/limits_check_show.jsp @@ -23,9 +23,7 @@ <% request.setCharacterEncoding("utf-8"); boolean flag = false; - PreparedStatement sql = null; - ResultSet rs = null; - Connection conn = null; + if (session.getAttribute("actualuser") == null) { out.println( ""); @@ -41,6 +39,10 @@ String use = "root"; String password = ""; Class.forName(driver); + try{ + PreparedStatement sql = null; + ResultSet rs = null; + Connection conn = null; conn = DriverManager.getConnection(url, use, password); sql = conn.prepareStatement("select * from show_user where userName=? and Administrator=1"); sql.setString(1, users); @@ -51,6 +53,9 @@ rs.close(); sql.close(); conn.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } %> <% diff --git a/WebRoot/JSPhandle/login.jsp b/WebRoot/JSPhandle/login.jsp index 29d1ce8..537a1c7 100644 --- a/WebRoot/JSPhandle/login.jsp +++ b/WebRoot/JSPhandle/login.jsp @@ -65,6 +65,7 @@ PreparedStatement vipsql = null; ResultSet viprs = null; Connection conn = null; + conn = DriverManager.getConnection(url, use, password); vipsql = conn.prepareStatement( "select userName,case when VIP = 1 then 'VIP用户' else '普通用户' end as VIP,case when Administrator = 1 then '管理员' else '' end as Administrator from show_user where userName=?"); vipsql.setString(1, users); diff --git a/WebRoot/JSPhandle/login_show.jsp b/WebRoot/JSPhandle/login_show.jsp index cfade58..1ced66d 100644 --- a/WebRoot/JSPhandle/login_show.jsp +++ b/WebRoot/JSPhandle/login_show.jsp @@ -1,47 +1,53 @@ -<%@ page language="java" import="java.util.*" - contentType="text/html;charset=utf-8"%> -<% - String path = request.getContextPath(); - String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() - + path + "/"; -%> +<%@ page language="java" import="java.util.*" contentType="text/html;charset=utf-8"%> +<% +String path = request.getContextPath(); +String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> <%@page import="java.sql.Connection"%> <%@page import="java.sql.*"%> <%@page import="java.sql.DriverManager"%> - - - - - -登录成功 - - - - - - - - - - - <% - java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - - java.util.Date currentTime = new java.util.Date();//得到当前系统时间 - - String str_date1 = formatter.format(currentTime); //将日期时间格式化 - String str_date2 = currentTime.toString(); //将Date型日期时间转换成字符串形式 + --> + + + + + <% +java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + +java.util.Date currentTime = new java.util.Date();//得到当前系统时间 + +String str_date1 = formatter.format(currentTime); //将日期时间格式化 +String str_date2 = currentTime.toString(); //将Date型日期时间转换成字符串形式 String driverClass = "com.mysql.jdbc.Driver"; String url = "jdbc:mysql://localhost:3306/db_school?useUnicode=true&characterEncoding=utf-8"; String user = "root"; String password = ""; + Object user0 = session.getAttribute("actualuser"); String counter = null; Class.forName(driverClass); - - Object user0 = session.getAttribute("actualuser"); + try{ + Connection conn = null; + conn = DriverManager.getConnection(url, user, password); + Statement stmt = conn.createStatement(); + stmt.close(); + conn.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } /* out.println("欢迎"+user0);//输出当前session用户 */ %> <%!public String getIpAddr(HttpServletRequest request) { @@ -57,45 +63,37 @@ } return ip; }%> - <% - counter = getIpAddr(request); - try { + <% + counter = getIpAddr(request); + try { + Connection conn = null; + PreparedStatement sql = null; + sql = conn.prepareStatement("update counter set visitCount=visitCount+1"); + int rtn = sql.executeUpdate(); + sql.close(); + conn.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + try { Connection conn = null; PreparedStatement sql = null; - conn = DriverManager.getConnection(url, user, password); - Statement stmt = conn.createStatement(); - sql = conn.prepareStatement("update counter set visitCount=visitCount+1"); - int rtn = sql.executeUpdate(); - stmt.close(); - sql.close(); - conn.close(); - } catch (Exception ex) { - ex.printStackTrace(); - } - try { - Connection conn = null; - PreparedStatement sql = null; - conn = DriverManager.getConnection(url, user, password); - Statement stmt = conn.createStatement(); - sql = conn.prepareStatement("insert into iplist(IP,times,userName)values(?,?,?)"); - sql.setString(1, counter); - sql.setString(2, str_date1); - sql.setString(3, (String) user0); - int rtn = sql.executeUpdate(); - stmt.close(); - sql.close(); - conn.close(); - } catch (Exception ex) { - ex.printStackTrace(); - } - %> - <% + sql = conn.prepareStatement("insert into iplist(IP,times,userName)values(?,?,?)"); + sql.setString(1, counter); + sql.setString(2, str_date1); + sql.setString(3, (String)user0); + int rtn = sql.executeUpdate(); + sql.close(); + conn.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + %> + <% + %> - 登录成功. -
- <% - response.setHeader("refresh", "0;url=../mainframe.jsp"); - %> - - + 登录成功.
+<% response.setHeader("refresh","0;url=../mainframe.jsp");%> + + \ No newline at end of file diff --git a/WebRoot/JSPhandle/signin_insert.jsp b/WebRoot/JSPhandle/signin_insert.jsp index 985728e..27cac37 100644 --- a/WebRoot/JSPhandle/signin_insert.jsp +++ b/WebRoot/JSPhandle/signin_insert.jsp @@ -35,7 +35,8 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request. String url="jdbc:mysql://localhost:3306/db_school?useUnicode=true&characterEncoding=utf-8"; String use = "root"; String password = ""; - Class.forName(driver); + Class.forName(driver); + try{ Connection conn= DriverManager.getConnection(url,use,password); PreparedStatement sql =conn.prepareStatement("insert into user(userName,password,Email,phoneNum)values(?,?,?,?)"); sql.setString(1,users); @@ -45,6 +46,9 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request. int rtn=sql.executeUpdate(); sql.close(); conn.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } %> <% response.setHeader("refresh","0;url=../signin_show.jsp");%> diff --git a/WebRoot/JSPhandle/user_delete.jsp b/WebRoot/JSPhandle/user_delete.jsp index 04a2541..18ea766 100644 --- a/WebRoot/JSPhandle/user_delete.jsp +++ b/WebRoot/JSPhandle/user_delete.jsp @@ -37,6 +37,7 @@ String use = "root"; String password = ""; Class.forName(driver); + try{ Connection conn = DriverManager.getConnection(url, use, password); PreparedStatement sql = conn .prepareStatement("delete from user where userName=?"); @@ -47,6 +48,9 @@ } sql.close(); conn.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } %> <% diff --git a/WebRoot/JSPhandle/user_update.jsp b/WebRoot/JSPhandle/user_update.jsp index 4be3f0c..96b7d83 100644 --- a/WebRoot/JSPhandle/user_update.jsp +++ b/WebRoot/JSPhandle/user_update.jsp @@ -40,6 +40,7 @@ String use = "root"; String password = ""; Class.forName(driver); + try{ Connection conn = DriverManager.getConnection(url, use, password); PreparedStatement sql = conn .prepareStatement("update user set userName=?,Email=?,Administrator = (case ? when '是' then '1'else '0' end ),VIP = (case ? when '是' then '1'else '0' end )where userName=?;"); @@ -54,6 +55,9 @@ } sql.close(); conn.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } %> <% diff --git a/WebRoot/JSPhandle/vipdownload_check_show.jsp b/WebRoot/JSPhandle/vipdownload_check_show.jsp index 6e9779f..ca23e0a 100644 --- a/WebRoot/JSPhandle/vipdownload_check_show.jsp +++ b/WebRoot/JSPhandle/vipdownload_check_show.jsp @@ -23,9 +23,7 @@ <% request.setCharacterEncoding("utf-8"); boolean flag = false; - PreparedStatement sql = null; - ResultSet rs = null; - Connection conn = null; + if (session.getAttribute("actualuser") == null) { out.println( ""); @@ -41,6 +39,10 @@ String use = "root"; String password = ""; Class.forName(driver); + try{ + PreparedStatement sql = null; + ResultSet rs = null; + Connection conn = null; conn = DriverManager.getConnection(url, use, password); sql = conn.prepareStatement("select * from show_user where userName=? and VIP=1"); sql.setString(1, users); @@ -51,6 +53,9 @@ rs.close(); sql.close(); conn.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } %> <% diff --git a/WebRoot/add_admin.jsp b/WebRoot/add_admin.jsp index 00bc566..c12822f 100644 --- a/WebRoot/add_admin.jsp +++ b/WebRoot/add_admin.jsp @@ -62,11 +62,12 @@ String url = "jdbc:mysql://localhost:3306/db_school?useUnicode=true&characterEncoding=utf-8"; String user = "root"; String password = ""; + + Class.forName(driverClass); + try { ResultSet rs = null; Connection conn = null; PreparedStatement sql = null; - try { - Class.forName(driverClass); conn = DriverManager.getConnection(url, user, password); Statement stmt = conn.createStatement(); sql = conn.prepareStatement("select * from administrator_job"); @@ -76,14 +77,16 @@ <% } + sql.close(); + rs.close(); + conn.close(); + stmt.close(); } catch (Exception ex) { ex.printStackTrace(); } %> <% - sql.close(); - rs.close(); - conn.close(); + %> diff --git a/WebRoot/change_admin.jsp b/WebRoot/change_admin.jsp index 04a6b1d..c01d358 100644 --- a/WebRoot/change_admin.jsp +++ b/WebRoot/change_admin.jsp @@ -41,11 +41,11 @@ String url = "jdbc:mysql://localhost:3306/db_school?useUnicode=true&characterEncoding=utf-8"; String user = "root"; String password = ""; + Class.forName(driverClass); + try { ResultSet rs = null; Connection conn = null; PreparedStatement sql = null; - try { - Class.forName(driverClass); conn = DriverManager.getConnection(url, user, password); Statement stmt = conn.createStatement(); sql = conn.prepareStatement("select * from adminstrator_record"); @@ -55,14 +55,16 @@ <% } + sql.close(); + rs.close(); + conn.close(); + stmt.close(); } catch (Exception ex) { ex.printStackTrace(); } %> <% - sql.close(); - rs.close(); - conn.close(); + %> diff --git a/WebRoot/change_user.jsp b/WebRoot/change_user.jsp index 3dc5c18..1fc83c5 100644 --- a/WebRoot/change_user.jsp +++ b/WebRoot/change_user.jsp @@ -62,11 +62,12 @@ String url = "jdbc:mysql://localhost:3306/db_school?useUnicode=true&characterEncoding=utf-8"; String user = "root"; String password = ""; + Class.forName(driverClass); + try { ResultSet rs = null; Connection conn = null; PreparedStatement sql = null; - try { - Class.forName(driverClass); + conn = DriverManager.getConnection(url, user, password); Statement stmt = conn.createStatement(); sql = conn.prepareStatement("select * from administrator_job"); @@ -76,14 +77,16 @@ <% } + sql.close(); + rs.close(); + conn.close(); + stmt.close(); } catch (Exception ex) { ex.printStackTrace(); } %> <% - sql.close(); - rs.close(); - conn.close(); + %> diff --git a/WebRoot/delete_admin.jsp b/WebRoot/delete_admin.jsp index 8cc3b21..3d380c6 100644 --- a/WebRoot/delete_admin.jsp +++ b/WebRoot/delete_admin.jsp @@ -42,10 +42,12 @@ String url = "jdbc:mysql://localhost:3306/db_school?useUnicode=true&characterEncoding=utf-8"; String user = "root"; String password = ""; + Class.forName(driverClass); + + try { ResultSet rs = null; Connection conn = null; PreparedStatement sql = null; - try { Class.forName(driverClass); conn = DriverManager.getConnection(url, user, password); Statement stmt = conn.createStatement(); @@ -56,14 +58,16 @@ <% } + sql.close(); + rs.close(); + conn.close(); + stmt.close(); } catch (Exception ex) { ex.printStackTrace(); } %> <% - sql.close(); - rs.close(); - conn.close(); + %> diff --git a/WebRoot/delete_job.jsp b/WebRoot/delete_job.jsp index 0cb9461..5db4286 100644 --- a/WebRoot/delete_job.jsp +++ b/WebRoot/delete_job.jsp @@ -42,11 +42,12 @@ String url = "jdbc:mysql://localhost:3306/db_school?useUnicode=true&characterEncoding=utf-8"; String user = "root"; String password = ""; + Class.forName(driverClass); + try { ResultSet rs = null; Connection conn = null; PreparedStatement sql = null; - try { - Class.forName(driverClass); + conn = DriverManager.getConnection(url, user, password); Statement stmt = conn.createStatement(); sql = conn.prepareStatement("select * from administrator_job"); @@ -56,14 +57,16 @@ <% } + sql.close(); + rs.close(); + conn.close(); + stmt.close(); } catch (Exception ex) { ex.printStackTrace(); } %> <% - sql.close(); - rs.close(); - conn.close(); + %> diff --git a/WebRoot/delete_user.jsp b/WebRoot/delete_user.jsp index fc40c06..6b68930 100644 --- a/WebRoot/delete_user.jsp +++ b/WebRoot/delete_user.jsp @@ -42,11 +42,12 @@ String url = "jdbc:mysql://localhost:3306/db_school?useUnicode=true&characterEncoding=utf-8"; String user = "root"; String password = ""; + Class.forName(driverClass); + try { ResultSet rs = null; Connection conn = null; PreparedStatement sql = null; - try { - Class.forName(driverClass); + conn = DriverManager.getConnection(url, user, password); Statement stmt = conn.createStatement(); sql = conn.prepareStatement("select * from show_user"); @@ -56,14 +57,16 @@ <% } + sql.close(); + rs.close(); + conn.close(); + stmt.close(); } catch (Exception ex) { ex.printStackTrace(); } %> <% - sql.close(); - rs.close(); - conn.close(); + %> diff --git a/WebRoot/edit_admin.jsp b/WebRoot/edit_admin.jsp index c26bf15..afe3518 100644 --- a/WebRoot/edit_admin.jsp +++ b/WebRoot/edit_admin.jsp @@ -33,9 +33,7 @@ String url = "jdbc:mysql://localhost:3306/db_school?useUnicode=true&characterEncoding=utf-8"; String user = "root"; String password = ""; - ResultSet rs = null; - Connection conn = null; - PreparedStatement sql = null; + Class.forName(driverClass); %> @@ -48,7 +46,9 @@
<% try { - Class.forName(driverClass); + ResultSet rs = null; + Connection conn = null; + PreparedStatement sql = null; conn = DriverManager.getConnection(url, user, password); Statement stmt = conn.createStatement(); sql = conn.prepareStatement("select * from adminstrator_record where AdminName=?"); @@ -83,6 +83,10 @@
<% } + sql.close(); + rs.close(); + conn.close(); + stmt.close(); } catch (Exception ex) { ex.printStackTrace(); } @@ -93,7 +97,9 @@ diff --git a/WebRoot/edit_user.jsp b/WebRoot/edit_user.jsp index 8c2e1d6..2357789 100644 --- a/WebRoot/edit_user.jsp +++ b/WebRoot/edit_user.jsp @@ -33,9 +33,7 @@ String url = "jdbc:mysql://localhost:3306/db_school?useUnicode=true&characterEncoding=utf-8"; String user = "root"; String password = ""; - ResultSet rs = null; - Connection conn = null; - PreparedStatement sql = null; + Class.forName(driverClass); %> @@ -48,7 +46,10 @@
<% try { - Class.forName(driverClass); + ResultSet rs = null; + Connection conn = null; + PreparedStatement sql = null; + conn = DriverManager.getConnection(url, user, password); Statement stmt = conn.createStatement(); sql = conn.prepareStatement("select userName,Email, VIP,Administrator from show_user where userName=?"); @@ -121,14 +122,16 @@
<% } + sql.close(); + rs.close(); + conn.close(); + stmt.close(); } catch (Exception ex) { ex.printStackTrace(); } %> <% - sql.close(); - rs.close(); - conn.close(); + %> diff --git a/WebRoot/exhibition_admin.jsp b/WebRoot/exhibition_admin.jsp index fcb43ca..0b3e865 100644 --- a/WebRoot/exhibition_admin.jsp +++ b/WebRoot/exhibition_admin.jsp @@ -114,11 +114,12 @@ String url = "jdbc:mysql://localhost:3306/db_school?useUnicode=true&characterEncoding=utf-8"; String user = "root"; String password = ""; + Class.forName(driverClass); + try { ResultSet rs = null; Connection conn = null; PreparedStatement sql = null; - try { - Class.forName(driverClass); + conn = DriverManager.getConnection(url, user, password); Statement stmt = conn.createStatement(); sql = conn.prepareStatement("select * from adminstrator_record"); @@ -153,6 +154,10 @@ <% } + sql.close(); + rs.close(); + conn.close(); + stmt.close(); } catch (Exception ex) { ex.printStackTrace(); } @@ -162,9 +167,7 @@ <% - sql.close(); - rs.close(); - conn.close(); + %> <%@ include file="module/footer.jsp"%> diff --git a/WebRoot/manage_user.jsp b/WebRoot/manage_user.jsp index 00bbd80..763e0c0 100644 --- a/WebRoot/manage_user.jsp +++ b/WebRoot/manage_user.jsp @@ -41,11 +41,12 @@ String url = "jdbc:mysql://localhost:3306/db_school?useUnicode=true&characterEncoding=utf-8"; String user = "root"; String password = ""; + Class.forName(driverClass); + try { ResultSet rs = null; Connection conn = null; PreparedStatement sql = null; - try { - Class.forName(driverClass); + conn = DriverManager.getConnection(url, user, password); Statement stmt = conn.createStatement(); sql = conn.prepareStatement("select * from show_user"); @@ -55,14 +56,16 @@ <% } + sql.close(); + rs.close(); + conn.close(); + stmt.close(); } catch (Exception ex) { ex.printStackTrace(); } %> <% - sql.close(); - rs.close(); - conn.close(); + %> diff --git a/WebRoot/show_admin.jsp b/WebRoot/show_admin.jsp index aca8433..4e77c1a 100644 --- a/WebRoot/show_admin.jsp +++ b/WebRoot/show_admin.jsp @@ -55,11 +55,11 @@ String url = "jdbc:mysql://localhost:3306/db_school?useUnicode=true&characterEncoding=utf-8"; String user = "root"; String password = ""; - ResultSet rs = null; - Connection conn = null; - PreparedStatement sql = null; + Class.forName(driverClass); try { - Class.forName(driverClass); + ResultSet rs = null; + Connection conn = null; + PreparedStatement sql = null; conn = DriverManager.getConnection(url, user, password); Statement stmt = conn.createStatement(); sql = conn.prepareStatement("select * from adminstrator_record"); @@ -75,14 +75,16 @@ <% } + sql.close(); + rs.close(); + conn.close(); + stmt.close(); } catch (Exception ex) { ex.printStackTrace(); } %> <% - sql.close(); - rs.close(); - conn.close(); + %> @@ -121,7 +123,10 @@ <% try { - Class.forName(driverClass); + ResultSet rs = null; + Connection conn = null; + PreparedStatement sql = null; + conn = DriverManager.getConnection(url, user, password); Statement stmt = conn.createStatement(); sql = conn.prepareStatement("select * from admin_view"); @@ -137,6 +142,10 @@ <% } + sql.close(); + rs.close(); + conn.close(); + stmt.close(); } catch (Exception ex) { ex.printStackTrace(); } @@ -158,9 +167,7 @@ <% - sql.close(); - rs.close(); - conn.close(); + %> <%@ include file="module/footer.jsp"%> diff --git a/WebRoot/show_adminjob.jsp b/WebRoot/show_adminjob.jsp index e9fe735..f8a7ec6 100644 --- a/WebRoot/show_adminjob.jsp +++ b/WebRoot/show_adminjob.jsp @@ -53,11 +53,12 @@ String url = "jdbc:mysql://localhost:3306/db_school?useUnicode=true&characterEncoding=utf-8"; String user = "root"; String password = ""; + Class.forName(driverClass); + try { ResultSet rs = null; Connection conn = null; PreparedStatement sql = null; - try { - Class.forName(driverClass); + conn = DriverManager.getConnection(url, user, password); Statement stmt = conn.createStatement(); sql = conn.prepareStatement("select * from administrator_job"); @@ -71,14 +72,16 @@ <% } + sql.close(); + rs.close(); + conn.close(); + stmt.close(); } catch (Exception ex) { ex.printStackTrace(); } %> <% - sql.close(); - rs.close(); - conn.close(); + %> diff --git a/WebRoot/show_user.jsp b/WebRoot/show_user.jsp index e8564c3..5d4a1bb 100644 --- a/WebRoot/show_user.jsp +++ b/WebRoot/show_user.jsp @@ -54,11 +54,12 @@ String url = "jdbc:mysql://localhost:3306/db_school?useUnicode=true&characterEncoding=utf-8"; String user = "root"; String password = ""; + Class.forName(driverClass); + try { ResultSet rs = null; Connection conn = null; PreparedStatement sql = null; - try { - Class.forName(driverClass); + conn = DriverManager.getConnection(url, user, password); Statement stmt = conn.createStatement(); sql = conn.prepareStatement( @@ -74,14 +75,16 @@ <% } + sql.close(); + rs.close(); + conn.close(); + stmt.close(); } catch (Exception ex) { ex.printStackTrace(); } %> <% - sql.close(); - rs.close(); - conn.close(); + %> diff --git a/WebRoot/x2_resource.jsp b/WebRoot/x2_resource.jsp index 1eb026b..e1241c9 100644 --- a/WebRoot/x2_resource.jsp +++ b/WebRoot/x2_resource.jsp @@ -56,11 +56,12 @@ String url = "jdbc:mysql://localhost:3306/db_school?useUnicode=true&characterEncoding=utf-8"; String user = "root"; String password = ""; + Class.forName(driverClass); + try { ResultSet rs = null; Connection conn = null; PreparedStatement sql = null; - try { - Class.forName(driverClass); + conn = DriverManager.getConnection(url, user, password); Statement stmt = conn.createStatement(); sql = conn.prepareStatement("select * from x2_resourse"); @@ -77,14 +78,16 @@ <% } + sql.close(); + rs.close(); + conn.close(); + stmt.close(); } catch (Exception ex) { ex.printStackTrace(); } %> <% - sql.close(); - rs.close(); - conn.close(); + %>