2020.12.7收获
志愿者信息管理系统
entity->Course.java
package entity; public class Course { private int id; private String name; private String sex; private String minzu; private String time; private String age; private String mianmao; private String fuwu; public Course() {} public Course(int id, String name, String sex, String minzu,String time,String age,String mianmao,String fuwu) { this.setId(id); this.setName(name); this.setSex(sex); this.setMinzu(minzu); this.setTime(time); this.setAge(age); this.setMianmao(mianmao); this.setFuwu(fuwu); } public Course(String name, String sex, String minzu,String time,String age,String mianmao,String fuwu) { this.setName(name); this.setSex(sex); this.setMinzu(minzu); this.setTime(time); this.setAge(age); this.setMianmao(mianmao); this.setFuwu(fuwu); } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getSex() { return sex; } public void setSex(String sex) { this.sex = sex; } public String getMinzu() { return minzu; } public void setMinzu(String minzu) { this.minzu = minzu; } public String getTime() { return time; } public void setTime(String time) { this.time = time; } public String getAge() { return age; } public void setAge(String age) { this.age = age; } public String getMianmao() { return mianmao; } public void setMianmao(String mianmao) { this.mianmao = mianmao; } public String getFuwu() { return fuwu; } public void setFuwu(String fuwu) { this.fuwu = fuwu; } }
util->DBUtil.java
package util; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class DBUtil { public static String db_url = "jdbc:mysql://localhost:3306/trycurd?useSSL=false&characterEncoding=UTF-8"; public static String db_user = "root"; public static String db_pass = "20183641"; public static Connection getConn () { Connection conn = null; try { Class.forName("com.mysql.jdbc.Driver"); conn = DriverManager.getConnection(db_url, db_user, db_pass); } catch (Exception e) { e.printStackTrace(); } return conn; } public static void close (Statement state, Connection conn) { if (state != null) { try { state.close(); } catch (SQLException e) { e.printStackTrace(); } } if (conn != null) { try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } } } public static void close (ResultSet rs, Statement state, Connection conn) { if (rs != null) { try { rs.close(); } catch (SQLException e) { e.printStackTrace(); } } if (state != null) { try { state.close(); } catch (SQLException e) { e.printStackTrace(); } } if (conn != null) { try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } } } }