From 6ef9b61fbaf4f20d372c221d6d953aae43797c7d Mon Sep 17 00:00:00 2001 From: zhai_lw Date: Tue, 8 Jan 2019 23:16:37 +0800 Subject: [PATCH] =?UTF-8?q?1,=20=E8=AE=BE=E7=BD=AEtomcat=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=202=EF=BC=8C=E9=85=8D=E7=BD=AE=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E8=BF=9E=E6=8E=A5=E6=B1=A0=203=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=B8=80=E7=B1=BBLastProcess=204=EF=BC=8C=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E7=9B=AE=E5=BD=95=E7=BB=93=E6=9E=84=205=EF=BC=8C?= =?UTF-8?q?=E5=85=B6=E4=BB=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GDMS.iml | 3 +- deployment/deploy.txt | 3 +- src/core/process/Condition.java | 4 -- src/core/process/LastProcess.java | 4 +- src/core/process/ProcessManagement.java | 14 +++--- src/core/user/User.java | 9 ---- src/dao/DBManagement.java | 58 ++++--------------------- src/init/Init.java | 2 +- web/WEB-INF/web.xml | 12 ----- 9 files changed, 21 insertions(+), 88 deletions(-) diff --git a/GDMS.iml b/GDMS.iml index 0ccb429..4bde68d 100644 --- a/GDMS.iml +++ b/GDMS.iml @@ -20,7 +20,7 @@ - + @@ -29,5 +29,6 @@ + \ No newline at end of file diff --git a/deployment/deploy.txt b/deployment/deploy.txt index d0952bc..4002c30 100644 --- a/deployment/deploy.txt +++ b/deployment/deploy.txt @@ -1,5 +1,4 @@ 0 windows home 1809 1 java jdk10 默认路径 2 tomcat8.5 默认路径 -3 mariaDB10.3 默认路径 -4 \ No newline at end of file +3 \ No newline at end of file diff --git a/src/core/process/Condition.java b/src/core/process/Condition.java index 9365dbb..4d62665 100644 --- a/src/core/process/Condition.java +++ b/src/core/process/Condition.java @@ -4,10 +4,6 @@ import java.util.ArrayList; import java.util.List; public class Condition { - public List getProcesses() { - return processes; - } - private List processes; public Process get(int index){ return processes.get(index); diff --git a/src/core/process/LastProcess.java b/src/core/process/LastProcess.java index 4c48117..316e405 100644 --- a/src/core/process/LastProcess.java +++ b/src/core/process/LastProcess.java @@ -2,7 +2,7 @@ package core.process; public class LastProcess extends Process{ - public LastProcess(String permission, String operationName, String processOptions, String info) throws Exception { - super(permission, operationName, processOptions, info); + public LastProcess(String info) { + super(info); } } diff --git a/src/core/process/ProcessManagement.java b/src/core/process/ProcessManagement.java index 7223a47..dbffd13 100644 --- a/src/core/process/ProcessManagement.java +++ b/src/core/process/ProcessManagement.java @@ -1,23 +1,23 @@ package core.process; import java.io.File; +import java.util.ArrayList; import java.util.List; import java.util.Map; public class ProcessManagement { - private List temporaryProcesses; - private Map> lastProcesses; - private List auxiliaryProcesses; + private List processes; + private Map> lastProcesses; public void setProcessesByJson(File file){ //todo } - public Process getTemporaryProcess(int index){ - return temporaryProcesses.get(index); + public Process getAtomProcess(int index){ + return processes.get(index); } public Condition getCondition(String userType, List index){ - Condition condition = new Condition(this.lastProcesses.get(userType)); + Condition condition = new Condition(lastProcesses.get(userType)); for(int i:index){ - condition.add(getTemporaryProcess(i)); + condition.add(getAtomProcess(i)); } return condition; } diff --git a/src/core/user/User.java b/src/core/user/User.java index 8048293..0f81d10 100644 --- a/src/core/user/User.java +++ b/src/core/user/User.java @@ -11,15 +11,6 @@ public abstract class User implements AccountManageable, ProcessConfigurable{ private String id; private String password; private List permissions = null; - - public Condition getCondition() { - return condition; - } - - public void setCondition(Condition condition) { - this.condition = condition; - } - private Condition condition; public void addPermission(String permission){ if(!permissions.contains(permission)) diff --git a/src/dao/DBManagement.java b/src/dao/DBManagement.java index 685c654..e597616 100644 --- a/src/dao/DBManagement.java +++ b/src/dao/DBManagement.java @@ -1,8 +1,11 @@ package dao; -import java.sql.*; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Properties; -import error.GExcptSQL; import org.apache.tomcat.jdbc.pool.DataSource; import org.apache.tomcat.jdbc.pool.PoolProperties; @@ -16,24 +19,20 @@ public class DBManagement { public static DataSource dataSource = new DataSource(); - private static boolean ifInit = false; - - public static void init(){ + public void init(){ PoolProperties poolProperties = new PoolProperties(); poolProperties.setUrl(url); poolProperties.setDriverClassName(driverClassName); poolProperties.setUsername(username); poolProperties.setPassword(password); dataSource.setPoolProperties(poolProperties); + } + public static Connection getConnection(){ try { Class.forName(driverClassName); } catch (ClassNotFoundException e) { e.printStackTrace(); } - ifInit = true; - } - public static Connection getConnection(){ - if(!ifInit) return null; try { return DriverManager.getConnection(url,username,password); } catch (SQLException e) { @@ -41,45 +40,4 @@ public class DBManagement { } return null; } - - public static ResultSet query(String sql) throws Exception { - if(!ifInit) return null; - ResultSet rs = null; - Connection con = null; - try{ - con = DBManagement.getConnection(); - Statement stmt = con.createStatement(); - rs = stmt.executeQuery(sql); - } catch (SQLException e) { - throw new GExcptSQL("Connect Failure"); - }finally { - if(con!=null) { - try { - con.close(); - } catch (SQLException e) { - throw new GExcptSQL("Connection Close Failure"); - } - } - } - return rs; - } - public static void update(String sql) throws GExcptSQL { - if(!ifInit) return; - Connection con = null; - try{ - con = DBManagement.getConnection(); - Statement stmt = con.createStatement(); - stmt.executeUpdate(sql); - } catch (SQLException e) { - throw new GExcptSQL("Connect Failure"); - }finally { - if(con!=null) { - try { - con.close(); - } catch (SQLException e) { - throw new GExcptSQL("Connection Close Failure"); - } - } - } - } } diff --git a/src/init/Init.java b/src/init/Init.java index 3d42bad..dfc60d4 100644 --- a/src/init/Init.java +++ b/src/init/Init.java @@ -13,7 +13,7 @@ import java.io.IOException; @WebServlet(name = "Init") public class Init extends HttpServlet { public void init(){ - DBManagement.init(); + new DBManagement().init(); new test(); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { diff --git a/web/WEB-INF/web.xml b/web/WEB-INF/web.xml index 37a5f89..3d93697 100644 --- a/web/WEB-INF/web.xml +++ b/web/WEB-INF/web.xml @@ -12,16 +12,4 @@ Init /init - - default - *.jpg - - - default - *.css - - - default - *.js - \ No newline at end of file