JAVA实训总结
随着实训的次数的增加,实训内容也逐渐深入,实训的深度也逐渐提高,但是只要我们足够努力,就会看到进步。
此次实训内容如下:
一、创建Java项目 - -----》学生信息管理系统(吴梦英)V1.0
在项目中创建了help,images,lib等文件夹,其中help中包含有帮助文档。images中传入了一些图片,以供备用。
(1)jar包的导入:
(2)帮助文档的导入:
在连接数据库中遇到了一些问题,经过我反复的上网查询,终于解决了问题,刚开始试过好几种解决方案都没有解决问题,这使得我感到非常浮躁,辛亏下来多坚持一会,就解决了问题,所以,当我们遇到问题是要善于调试自己的心态,善于尝试,要有耐心,总会找到解决问题的办法。
在src里创建net.hw.student.bean包
依次创建四个实体类:College、Status、Student与User,分别对应t_college表、t_status表、t_student表与t_user表。
1、创建学校实体类对应学校表
代码如下:
package net.wmy.student.bean;
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 + '\'' +
'}';
}
}
状态实体类代码如下所示:
在这里插入代码片package net.wmy.student.bean;
//功能:状态实体类
public class Status {
private int id; // 状态标识符
private String college; // 校名
private String version; // 软件版本
private String author; // 软件作者
private String telephone; // 联系电话
private String address; // 通信地址
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 getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
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 + '\'' +
", telephone='" + telephone + '\'' +
", address='" + address + '\'' +
", email='" + email + '\'' +
'}';
}
}
package net.wmy.student.bean;
//功能:学生实体类
public class Student {
private String id; // 学号
private String name; // 姓名
private String sex; // 性别
private int age; // 年龄
private String department; // 系部
private String clazz; // 班级
private String telephone; // 联系电话
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 int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public String getClazz() {
return clazz;
}
public void setClazz(String clazz) {
this.clazz = clazz;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
@Override
public String toString() {
return "Student{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
", sex='" + sex + '\'' +
", age=" + age +
", department='" + department + '\'' +
", clazz='" + clazz + '\'' +
", telephone='" + telephone + '\'' +
'}';
}
}
4、创建用户实体类对应用户表
package net.wmy.student.bean;
import java.sql.Timestamp;
import java.util.Date;
/**
* 功能:用户实体类
*/
public class User {
private int id; // 用户标识符
private String username; // 用户名
private String password; // 密码
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 getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public Date getRegisterTime() {
return registerTime;
}
public void setRegisterTime(Timestamp registerTime2) {
this.registerTime = registerTime2;
}
@Override
public String toString() {
return "User{" +
"id=" + id +
", username='" + username + '\'' +
", password='" + password + '\'' +
", telephone='" + telephone + '\'' +
", registerTime=" + registerTime +
'}';
}
}
((4)删除记录如下图代码:
(4)更新记录如下图所示:
总结:老师让我们亲自动手自己实践,我们找到许多自己的不足之处,所以,常常动手才会让我们体会更深。