1, 设置tomcat服务器

2,配置数据库连接池
3,增加一类LastProcess
4,调整目录结构
5,其他
wlf
zhai_lw 6 years ago
parent a3da87241b
commit 6ef9b61fba

@ -20,7 +20,7 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Tomcat 8.5.37" level="application_server_libraries" />
<orderEntry type="module-library">
<orderEntry type="module-library" scope="PROVIDED">
<library>
<CLASSES>
<root url="jar://C:/Program Files/Apache Software Foundation/Tomcat 8.5/lib/tomcat-jdbc.jar!/" />
@ -29,5 +29,6 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" scope="PROVIDED" name="mariadb-java-client-2.3.0" level="project" />
</component>
</module>

@ -1,5 +1,4 @@
0 windows home 1809
1 java jdk10 默认路径
2 tomcat8.5 默认路径
3 mariaDB10.3 默认路径
4
3

@ -4,10 +4,6 @@ import java.util.ArrayList;
import java.util.List;
public class Condition {
public List<Process> getProcesses() {
return processes;
}
private List<Process> processes;
public Process get(int index){
return processes.get(index);

@ -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);
}
}

@ -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<TemporaryProcess> temporaryProcesses;
private Map<String, List<Process>> lastProcesses;
private List<AuxiliaryProcess> auxiliaryProcesses;
private List<AtomProcess> processes;
private Map<String,List<Process>> 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<Integer> 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;
}

@ -11,15 +11,6 @@ public abstract class User implements AccountManageable, ProcessConfigurable{
private String id;
private String password;
private List<String> 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))

@ -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");
}
}
}
}
}

@ -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 {

@ -12,16 +12,4 @@
<servlet-name>Init</servlet-name>
<url-pattern>/init</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.jpg</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.css</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.js</url-pattern>
</servlet-mapping>
</web-app>
Loading…
Cancel
Save