1, 设置tomcat服务器

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

@ -7,9 +7,6 @@
<element id="directory" name="classes">
<element id="module-output" name="GDMS" />
</element>
<element id="directory" name="lib">
<element id="file-copy" path="$MAVEN_REPOSITORY$/org/jetbrains/annotations/16.0.2/annotations-16.0.2.jar" />
</element>
</element>
</root>
</artifact>

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="@localhost:gdms" uuid="356b1cbb-8e8d-401f-bdfc-b3e917bc8301">
<driver-ref>mariadb</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.mariadb.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mariadb://localhost:3306/gdms</jdbc-url>
<driver-properties>
<property name="autoReconnect" value="true" />
<property name="zeroDateTimeBehavior" value="convertToNull" />
<property name="tinyInt1isBit" value="false" />
<property name="characterEncoding" value="utf8" />
<property name="characterSetResults" value="utf8" />
<property name="yearIsDateType" value="false" />
</driver-properties>
</data-source>
</component>
</project>

@ -1,6 +1,8 @@
<component name="ProjectDictionaryState">
<dictionary name="zhai_">
<words>
<w>gdms</w>
<w>mariadb</w>
<w>synchronizable</w>
</words>
</dictionary>

@ -19,14 +19,16 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<orderEntry type="library" scope="PROVIDED" name="Tomcat 8.5.37" level="application_server_libraries" />
<orderEntry type="module-library" scope="PROVIDED">
<library>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/16.0.2/annotations-16.0.2.jar!/" />
<root url="jar://C:/Program Files/Apache Software Foundation/Tomcat 8.5/lib/tomcat-jdbc.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" scope="PROVIDED" name="mariadb-java-client-2.3.0" level="project" />
</component>
</module>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource type="javax.sql.DataSource"
name="jdbc/gdms"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mariadb://localhost:3306/gdms"
username="gdms"
password="GDMS"/>
</Context>

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

@ -0,0 +1 @@
CREATE DATABASE `GDMS`;

Before

Width:  |  Height:  |  Size: 101 KiB

After

Width:  |  Height:  |  Size: 101 KiB

Before

Width:  |  Height:  |  Size: 286 KiB

After

Width:  |  Height:  |  Size: 286 KiB

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Before

Width:  |  Height:  |  Size: 382 KiB

After

Width:  |  Height:  |  Size: 382 KiB

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 62 KiB

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

@ -1,4 +0,0 @@
package core.process;
public class APSet {
}

@ -1,11 +0,0 @@
package core.process;
import java.util.List;
public class CompoundProcess extends Process {
private List<Process> processes;
public CompoundProcess(String info) {
super(info);
}
}

@ -0,0 +1,23 @@
package core.process;
import java.util.ArrayList;
import java.util.List;
public class Condition {
private List<Process> processes;
public Process get(int index){
return processes.get(index);
}
public Condition(List<Process> processes){
this.processes=processes;
}
public Condition(){
processes = new ArrayList<>();
}
public void add(Process process){
this.processes.add(process);
}
public void add(List<Process> processes){
this.processes.addAll(processes);
}
}

@ -0,0 +1,8 @@
package core.process;
public class LastProcess extends Process{
public LastProcess(String info) {
super(info);
}
}

@ -1,10 +1,25 @@
package core.process;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class ProcessManagement {
private CompoundProcess processes;
private List<AtomProcess> processes;
private Map<String,List<Process>> lastProcesses;
public void setProcessesByJson(File file){
//todo
}
public Process getAtomProcess(int index){
return processes.get(index);
}
public Condition getCondition(String userType, List<Integer> index){
Condition condition = new Condition(lastProcesses.get(userType));
for(int i:index){
condition.add(getAtomProcess(i));
}
return condition;
}
}

@ -1,11 +1,9 @@
package core.user;
import core.process.APSet;
import core.process.ProcessManagement;
import core.process.Condition;
import core.user.userFun.AccountManageable;
import core.user.userFun.ProcessConfigurable;
import java.io.File;
import java.util.List;
public abstract class User implements AccountManageable, ProcessConfigurable{
@ -13,7 +11,7 @@ public abstract class User implements AccountManageable, ProcessConfigurable{
private String id;
private String password;
private List<String> permissions = null;
private APSet condition;
private Condition condition;
public void addPermission(String permission){
if(!permissions.contains(permission))
permissions.add(permission);

@ -0,0 +1,43 @@
package dao;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
import org.apache.tomcat.jdbc.pool.DataSource;
import org.apache.tomcat.jdbc.pool.PoolProperties;
public class DBManagement {
static final String driverClassName="org.mariadb.jdbc.Driver";
static final String url="jdbc:mariadb://localhost:3306/gdms";
static final String username="gdms";
static final String password="GDMS";
public static DataSource dataSource = new DataSource();
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();
}
try {
return DriverManager.getConnection(url,username,password);
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
}

@ -1,4 +1,6 @@
package dao;
public interface Utils {
}

@ -1,16 +1,49 @@
package gdms;
import core.user.Student;
import core.user.User;
import dao.DBManagement;
import org.apache.tomcat.jdbc.pool.DataSource;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.lang.reflect.InvocationTargetException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class test {
public static void main(String argc[]){
String sTest = "-a add -s set -d delete";
Map<String,Object> test = core.operation.utils.util.string2MapOptions(sTest);
System.out.println(test);
public test(){
Connection con = null;
try{
con = DBManagement.getConnection();
Statement stmt = con.createStatement(); //创建Statement对象
System.out.print("成功连接到数据库!");
String sql = "select * from test";
ResultSet rs = stmt.executeQuery(sql);
rs.next();
System.out.println(rs.getString("name"));
rs.close();
stmt.close();
con.close();
}catch (Exception e){
e.printStackTrace();
}finally {
if(con!=null) {
try {
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
public static void main(String argc[]) throws NamingException, SQLException {
new test();
}
}

@ -0,0 +1,26 @@
package init;
import dao.DBManagement;
import gdms.test;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet(name = "Init")
public class Init extends HttpServlet {
public void init(){
new DBManagement().init();
new test();
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
}

@ -3,4 +3,13 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<servlet>
<servlet-name>Init</servlet-name>
<servlet-class>init.Init</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Init</servlet-name>
<url-pattern>/init</url-pattern>
</servlet-mapping>
</web-app>
Loading…
Cancel
Save