Skip to content

Commit ca6d677

Browse files
capzoroiLoveMasami
authored andcommitted
init-database
1 parent 7a630fd commit ca6d677

File tree

11 files changed

+228
-12
lines changed

11 files changed

+228
-12
lines changed

SHStudentManagementSystem/.idea/SSHStudentManagementSystem.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SHStudentManagementSystem/.idea/encodings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SHStudentManagementSystem/.idea/misc.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SHStudentManagementSystem/src/hibernate.cfg.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<property name="connection.username">root</property>
88
<property name="connection.password">root</property>
99
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
10-
<property name="connection.url">jdbc:mysql://localhost:3306/imooc_student_system</property>
10+
<property name="connection.url">jdbc:mysql://localhost:3306/student_system</property>
1111
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
1212
<property name="show_sql">true</property>
1313
<property name="format_sql">true</property>

mega-manage/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
### 项目简介
22
由Maven重新搭建学生管理系统SHStudentManagementSystem,目前只生成了Maven项目的框架。
3+
### 启动步骤
4+
#### 本地启动步骤
5+
1. 配置数据库环境,数据库使用Mysql8。首先创建mega_student_system数据库,字符集选择UTF-8,然后相关DDL和DML可以通过src\test\java\entity\InitDatabase.java中相关方法实现。
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package com.ilovemasami.entity;
2+
3+
import java.util.Date;
4+
5+
/**
6+
* @author yuzhezhu
7+
* @date 2020/01/22
8+
**/
9+
public class Students {
10+
private String sid;
11+
private String sname;
12+
private String gender;
13+
private Date birthday;
14+
private String address;
15+
16+
public Students() {
17+
}
18+
19+
public Students(String sid, String sname, String gender, Date birthday, String address) {
20+
this.sid = sid;
21+
this.sname = sname;
22+
this.gender = gender;
23+
this.birthday = birthday;
24+
this.address = address;
25+
}
26+
27+
public String getSid() {
28+
return sid;
29+
}
30+
31+
public void setSid(String sid) {
32+
this.sid = sid;
33+
}
34+
35+
public String getSname() {
36+
return sname;
37+
}
38+
39+
public void setSname(String sname) {
40+
this.sname = sname;
41+
}
42+
43+
public String getGender() {
44+
return gender;
45+
}
46+
47+
public void setGender(String gender) {
48+
this.gender = gender;
49+
}
50+
51+
public Date getBirthday() {
52+
return birthday;
53+
}
54+
55+
public void setBirthday(Date birthday) {
56+
this.birthday = birthday;
57+
}
58+
59+
public String getAddress() {
60+
return address;
61+
}
62+
63+
public void setAddress(String address) {
64+
this.address = address;
65+
}
66+
67+
@Override
68+
public String toString() {
69+
return "Students{" +
70+
"sid='" + sid + '\'' +
71+
", sname='" + sname + '\'' +
72+
", gender='" + gender + '\'' +
73+
", birthday=" + birthday +
74+
", address='" + address + '\'' +
75+
'}';
76+
}
77+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.ilovemasami.entity;
2+
3+
/**
4+
* @author yuzhezhu
5+
* @date 2020/01/22
6+
**/
7+
public class Users {
8+
private Integer uid;
9+
private String username;
10+
private String password;
11+
12+
public Users() {
13+
}
14+
15+
public Users(Integer uid, String username, String password) {
16+
this.uid = uid;
17+
this.username = username;
18+
this.password = password;
19+
}
20+
21+
public Integer getUid() {
22+
return uid;
23+
}
24+
25+
public void setUid(Integer uid) {
26+
this.uid = uid;
27+
}
28+
29+
public String getUsername() {
30+
return username;
31+
}
32+
33+
public void setUsername(String username) {
34+
this.username = username;
35+
}
36+
37+
public String getPassword() {
38+
return password;
39+
}
40+
41+
public void setPassword(String password) {
42+
this.password = password;
43+
}
44+
45+
@Override
46+
public String toString() {
47+
return "Users{" +
48+
"uid=" + uid +
49+
", username='" + username + '\'' +
50+
", password='" + password + '\'' +
51+
'}';
52+
}
53+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
3+
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
4+
<!-- package需要写上,不然找不到映射类-->
5+
<hibernate-mapping package="com.ilovemasami.entity">
6+
<class name="com.ilovemasami.entity.Students" table="STUDENTS">
7+
<id name="sid" type="java.lang.String">
8+
<generator class="assigned" />
9+
</id>
10+
<property name="sname" type="java.lang.String">
11+
<column name="sname" />
12+
</property>
13+
<property name="gender" type="java.lang.String">
14+
<column name="gender" />
15+
</property>
16+
<property name="birthday" type="date">
17+
<column name="birthday" />
18+
</property>
19+
<property name="address" type="java.lang.String">
20+
<column name="address" />
21+
</property>
22+
</class>
23+
</hibernate-mapping>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
3+
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
4+
<hibernate-mapping package="com.ilovemasami.entity">
5+
<class name="com.ilovemasami.entity.Users" table="USERS">
6+
<id name="uid" type="java.lang.Integer">
7+
<column name="uid" />
8+
<generator class="native" />
9+
</id>
10+
<property name="username" type="java.lang.String">
11+
<column name="username" />
12+
</property>
13+
<property name="password" type="java.lang.String">
14+
<column name="password" />
15+
</property>
16+
</class>
17+
</hibernate-mapping>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE hibernate-configuration PUBLIC
3+
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
4+
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
5+
<hibernate-configuration>
6+
<session-factory>
7+
<property name="connection.username">root</property>
8+
<property name="connection.password">root</property>
9+
<property name="connection.driver_class">com.mysql.cj.jdbc.Driver</property>
10+
<!-- mysql8需要加上时区-->
11+
<property name="connection.url">jdbc:mysql://localhost:3306/mega_student_system?useSSL=false&amp;serverTimezone=Asia/Shanghai</property>
12+
<!-- 使用MySQL8Dialect创建InnonDB引擎的数据表,MySQLDialect则是MyIsam-->
13+
<property name="dialect">org.hibernate.dialect.MySQL8Dialect</property>
14+
<property name="show_sql">true</property>
15+
<property name="format_sql">true</property>
16+
<property name="hibernate.hbm2ddl.auto">update</property>
17+
<property name="hibernate.current_session_context_class">thread</property>
18+
19+
<mapping resource="Students.hbm.xml" />
20+
<mapping resource="Users.hbm.xml" />
21+
</session-factory>
22+
</hibernate-configuration>

0 commit comments

Comments
 (0)