本学期的Java课程已经结束,本学期剩下的一个月也进入到了实训周,对于Java课程,我们的实训项目为学生信息管理系统!以下是本项目记录。
第一步:我们运用百度脑图做了学生管理系统的流程图
第二步:新建数据库
1、新建student表
2、新建college表
3、新建user表
4、创建status表
第三步:项目实体化
1、进行学校实体化
package net.Caoxinru.student.bean;
import javax.xml.crypto.Data;
import java.util.Date;
/**
public class College {
/**
* 学校标识
/
private int id;
/*
* 学校名称
/
private String name;
/*
* 校长
/
private String president;
/*
* 建校时间
/
private Date startTime;
/*
* 联系电话
/
private String telephone;
/*
* 电子邮箱
/
private String email;
/*
* 通讯地址
/
private String address;
/*
* 学校简介
*/
private String profile;
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 getPresident() {
return president;
}
public void setPresident(String president) {
this.president = president;
}
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getProfile() {
return profile;
}
public void setProfile(String profile) {
this.profile = profile;
}
@Override
public String toString() {
return "College{" +
"id=" + id +
", name='" + name + '\'' +
", president='" + president + '\'' +
", startTime=" + startTime +
", telephone='" + telephone + '\'' +
", email='" + email + '\'' +
", address='" + address + '\'' +
", profile='" + profile + '\'' +
'}';
}
}
2、进行状态实体化
package net.Caoxinru.student.bean;
/**
public class Status {
public int id;
private String college;
private String version;
private String author;
private String telephon;
private String addtress;
private String email;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getCollege() {
return college;
}
public void setCollege(String college) {
this.college = college;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getTelephon() {
return telephon;
}
public void setTelephon(String telephon) {
this.telephon = telephon;
}
public String getAddtress() {
return addtress;
}
public void setAddtress(String addtress) {
this.addtress = addtress;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Override
public String toString() {
return "Status{" +
"id=" + id +
", college='" + college + '\'' +
", version='" + version + '\'' +
", author='" + author + '\'' +
", telephon='" + telephon + '\'' +
", addtress='" + addtress + '\'' +
", email='" + email + '\'' +
'}';
}
}
3、进行学生实体化
package net.Caoxinru.student.bean;
/**
public class Student {
private String id;
private String name;
private String sex;
private String age;
private String department;
private String clazz;
private String telephon;
public String getId() {
return id;
}
public void setId(String 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 getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String getDepartment() {
return department;
}
@Override
public String toString() {
return "Student{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
", sex='" + sex + '\'' +
", age='" + age + '\'' +
", department='" + department + '\'' +
", clazz='" + clazz + '\'' +
", telephon='" + telephon + '\'' +
'}';
}
public void setDepartment(String department) {
this.department = department;
}
public String getClazz() {
return clazz;
}
public void setClazz(String clazz) {
this.clazz = clazz;
}
public String getTelephon() {
return telephon;
}
public void setTelephon(String telephon) {
this.telephon = telephon;
}
}
4、进行用户实体化
package net.Caoxinru.student.bean;
import java.util.Date;
/**
包名:net.Ccaoxinru.student.bean
类名:User
描述:用户实体
作者:曹鑫如
日期:2019年6月17日
*/
public class User {
private int id;
private String username;
private String password;
private String passwordd;
private String telephone;
private Date registerTime;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getPasswordd() {
return passwordd;
}
public void setPasswordd(String passwordd) {
this.passwordd = passwordd;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public Date getRegisterTime() {
return registerTime;
}
public void setRegisterTime(Date registerTime) {
this.registerTime = registerTime;
}
@Override
public String toString() {
return “User{” +
“id=” + id +
“, username=’” + username + ‘’’ +
“, password=’” + password + ‘’’ +
“, passwordd=’” + passwordd + ‘’’ +
“, telephone=’” + telephone + ‘’’ +
“, registerTime=” + registerTime +
‘}’;
}
}
第四步:连接数据库
package net.Caoxinru.student.dbutil;
import javax.swing.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
/**
功能:数据库连接管理类
作者:曹鑫如
日期:2019年6月17日
/
public class ConnectionManager {
/*
/**
/**
/**
/**
测试数据库连接是否成功
@param args
*/
public static void main(String[] args) {
// 获得数据库连接
Connection conn = getConnection();
// 判断是否连接成功
if (conn != null) {
JOptionPane.showMessageDialog(null, “恭喜,数据库连接成功!”);
} else {
JOptionPane.showMessageDialog(null, “遗憾,数据库连接失败!”);
}
// 关闭数据库连接
closeConnection(conn);
}