新生基本信息管理系统java_Java课程设计 学生基本信息管理系统 团队博客

学生基本信息管理系统团队博客

项目git地址

项目git提交记录截图

f9717b23c8c4787833c5bc279bff35ae.png

项目功能架构图与主要功能流程图

项目功能构架图:

6432d2597fa17574975f9d9129959cb7.png

主要功能流程图:

e2c64b7722cdf8d92b10d7a038074824.png

项目运行截图

510db44f542036888233dbdfced5ddbb.png

a0a33b107f89357c2d5d40419f57f08a.png

7ebb8346d7d07d4df4d01cc2c6b64e9f.png

5579ac508484bb0173364b8c0cfb6217.png

6c93dcf75fee24e87f5bc13fb9a59b89.png

84dc1420c40acf3dad8bb73a3d9b6107.png

a4f60719966b3ed80754827e6a1a099b.png

648204871daa2421a31ad2edb73f7a26.png

39eecff2507c96d6be284e6a8d93d591.png

c5614dde86513379dcaa533b31723ba2.png

426981e526a7047bf02f294801c0ce0e.png

cbf38b63a06d34cc12ddb5eddabc9950.png

9358502e22565feb0e4a05a5cebf6bfa.png

c95767dc7e6de6668347f075f5c0ec80.png

项目关键代码

连接数据库的类代码:

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

public class DBUtil {

private static final String URL = "jdbc:mysql://localhost:3306/student";

private static final String NAME = "root";

private static final String PASSWORD = "123456";

public static void exec(String str) throws ClassNotFoundException, SQLException {

// 1.加载驱动程序

Class.forName("com.mysql.jdbc.Driver");

// 2.获得数据库的连接

Connection conn = DriverManager.getConnection(URL, NAME, PASSWORD);

// 3.通过数据库的连接操作数据库,实现增删改查

Statement stmt = conn.createStatement();

stmt.execute(str);

stmt.close();

conn.close();

}

static ResultSet query(String sql) throws SQLException, ClassNotFoundException {

Class.forName("com.mysql.jdbc.Driver");

// 1.获得数据库的连接

Connection conn = DriverManager.getConnection(URL, NAME, PASSWORD);

// 2.通过数据库的连接操作数据库,实现增删改查

Statement stmt = conn.createStatement();

try {

return stmt.executeQuery(sql);

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

return null;

}

}

增加方法的函数:

package database;

import database.DBUtil;

import java.sql.*;

public class ADD{

public static void add(String number,String name,String gender,String birthdate,String politics,String address,String telephone,String dormitory){

String str = "insert into students(number,name,gender,birthdate,politics,address,telephone,dormitory)"

+ " values("+"'"+number+"'"+"," + "'"+name+"'"+"," +"'"+ gender+"'"+"," +"'"+ birthdate+"'"+"," +"'"+ politics+"'" +","+"'"+ address+"'"+"," +"'"+telephone+"'"+"," +"'"+ dormitory+"'"+")";

try {

DBUtil.exec(str);

} catch (ClassNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

更改的函数:

public class CHANGE {

public static void change(String number, String name, String gender, String birthdate, String politics,

String address, String telephone, String dormitory) {

String str = "update students set number='" + number + "',gender='" + gender + "'," + "birthdate='" + birthdate

+ "'," + "politics='" + politics + "'," + "address='" + address + "'," + "telephone='" + telephone

+ "'," + "dormitory='" + dormitory + "' " + "where name=" + "'" + name + "';";

try {

System.out.println(str);

DBUtil.exec(str);

} catch (ClassNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

删除的函数:

public class DELETE {

public static String[][] delete(String name){

String str ="delete from students where name="+"'"+name+"'"+";";

String[][] strs = new String[100][8];

try{

DBUtil.exec(str);

}catch (ClassNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

return strs;

}

}

搜索的函数:

public class SEARCH {

public static String[][] serach(String name){

String str = "select * from students where name="+"'"+name+"'"+";";

String[][] strs = new String[100][8];

try{

ResultSet resultSet = DBUtil.query(str);

int cnt = 0;

while (resultSet.next()) {

for (int i = 0; i < 8; i++) {

strs[cnt][i] = resultSet.getString(i + 1);

}

cnt++;

}

}catch (ClassNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

return strs;

}

}

尚待改进或者新的想法

尚待改进的:

①由于时间太少,所以界面做的很粗糙and 丑。

②可以在新增加一个注册管理员的功能,注册管理员然后用注册的账号登陆信息管理系统。

③在更改数据库信息的时候可以只更新部分信息,不更新全部的信息,然而在设计的系统里面只能更改全部的信息。

④最后打包成jar包可以在包装成exe。

团队成员任务分配,团队成员课程设计博客链接(以表格形式呈现),标明组长

package cn.com.dao.chivementdao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import cn.com.util.DBConnection; import cn.com.util.DBSql; import cn.com.vo.chivementvo.ChivementVo; public class ExamDao { private Connection conn = DBConnection.getConnectionOracle(); private ChivementVo examVo; public ExamDao() { } public ExamDao(ChivementVo examVo) { super(); this.examVo = examVo; } /** * 全部查询 */ public Object[][] selectAll() { Object date[][] = null; int max = 0; int i = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(DBSql.SELECT_ALL); rs = ps.executeQuery(); // 得到列数 max = rs.getMetaData().getColumnCount(); date = new Object[getnumberAll(DBSql.SELECT_ALL_COUNT)][max]; while (rs.next()) { for (int j = 0; j < max; j++) { date[i][j] = rs.getObject(j + 1); } i++; } // rs.close(); // ps.close(); // conn.close(); } catch (SQLException e) { e.printStackTrace(); } return date; } /** * 根据学号查询 */ public Object[][] selectBySid() { Object date[][] = null; int max = 0; int i = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(DBSql.SELECT_BY_S_ID); ps.setInt(1, examVo.getS_id()); rs = ps.executeQuery(); // 得到列数 max = rs.getMetaData().getColumnCount(); date = new Object[getnumber(DBSql.SELECT_BY_S_ID_COUNT, examVo .getS_id())][max]; while (rs.next()) { for (int j = 0; j < max; j++) { date[i][j] = rs.getObject(j + 1); } i++; } // rs.close(); // ps.close(); // conn.close(); } catch (SQLException e) { e.printStackTrace(); } return date; } /** * 根据组号查询 */ public Object[][] selectByGid() { Object date[][] = null; int max = 0; int i = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(DBSql.SELECT_BY_G_ID); ps.setInt(1, examVo.getG_id()); rs = ps.executeQuery(); // 得到列数 max = rs.getMetaData().getColumnCount(); date = new Object[getnumber(DBSql.SELECT_BY_G_ID_COUNT, examVo .getG_id())][max]; while (rs.next()) { for (int j = 0; j < max; j++) { date[i][j] = rs.getObject(j + 1); } i++; } // rs.close(); // ps.close(); // conn.close(); } catch (SQLException e) { e.printStackTrace(); } return date; } /** * 根据课程号查询 */ public Object[][] selectByCid() { Object date[][] = null; int max = 0; int i = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(DBSql.SELECT_BY_C_ID); ps.setInt(1, examVo.getC_id()); rs = ps.executeQuery(); // 得到列数 max = rs.getMetaData().getColumnCount(); date = new Object[getnumber(DBSql.SELECT_BY_C_ID_COUNT, examVo .getC_id())][max]; while (rs.next()) { for (int j = 0; j < max; j++) { // System.out.println( examVo.getG_id()); date[i][j] = rs.getObject(j+1); } i++; } // rs.close(); // ps.close(); // conn.close(); } catch (SQLException e) { e.printStackTrace(); } return date; } /** * 根据姓名模糊查询 * * @return */ public Object[][] selectByName() { Object date[][] = null; int max = 0; int i = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(DBSql.SELECT_BY_S_NAME); ps.setString(1, examVo.getS_name()); ps.setString(2, "%" + examVo.getS_name() + "%"); ps.setString(3, "%" + examVo.getS_name()); ps.setString(4, examVo.getS_name() + "%"); rs = ps.executeQuery(); // 得到列数 max = rs.getMetaData().getColumnCount(); date = new Object[getnumberByName(DBSql.SELECT_BY_S_NAME_COUNT, examVo.getS_name())][max]; while (rs.next()) { for (int j = 0; j < max; j++) { date[i][j] = rs.getObject(j + 1); } i++; } } catch (SQLException e) { e.printStackTrace(); } return date; } /** * 根据课程名称模糊查询 * * @return */ public Object[][] selectByClassName() { Object date[][] = null; int max = 0; int i = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(DBSql.SELECT_BY_CLASS_NAME); ps.setString(1, examVo.getClass_name()); ps.setString(2, "%" + examVo.getClass_name() + "%"); ps.setString(3, "%" + examVo.getClass_name()); ps.setString(4, examVo.getClass_name() + "%"); rs = ps.executeQuery(); // 得到列数 max = rs.getMetaData().getColumnCount(); date = new Object[getnumberByName(DBSql.SELECT_BY_CLASS_COUNT, examVo.getClass_name())][max]; while (rs.next()) { for (int j = 0; j < max; j++) { date[i][j] = rs.getObject(j + 1); } i++; } } catch (SQLException e) { e.printStackTrace(); } return date; } /** * 修改选中学生的成绩 * */ public void updatSelectClass() { PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(DBSql.UPDATE_EXAM_BY_STUID); ps.setInt(1, examVo.getClassExamChivement()); ps.setInt(2, examVo.getS_id()); ps.setInt(3, examVo.getC_id()); ps.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } } /** * 得到所有课程号和课程名 * * @return */ public String[] getClassNoName() { String[] classNoName = null; PreparedStatement ps = null; ResultSet rs = null; int j = 0; try { int i = getnumberAll(DBSql.SELECT_CLASS_NAME_COUNT); classNoName = new String[i + i]; ps = conn.prepareStatement(DBSql.SELECT_CLASS_NAME); rs = ps.executeQuery(); while (rs.next()) { classNoName[j] = rs.getString(1); classNoName[j + i] = rs.getString(2); j++; } } catch (SQLException e) { e.printStackTrace(); } return classNoName; } /** * 根据科目修改成绩 查询学号 姓名 成绩 * */ public void SelectClassStuName() { int i = 0; PreparedStatement ps = null; ResultSet rs = null; int j = getnumberBySelectClassName( DBSql.SELECT_CLASS_STU_SNO_SNAME_EXAM_COUNT, examVo.getC_id()); int[] sNum = new int[j]; String[] sName = new String[j]; int[] classExam = new int[j]; try { ps = conn.prepareStatement(DBSql.SELECT_CLASS_STU_SNO_SNAME_EXAM); ps.setInt(1, examVo.getC_id()); rs = ps.executeQuery(); while (rs.next()) { sNum[i] = rs.getInt(1); sName[i] = rs.getString(2); classExam[i] = rs.getInt(3); i++; } } catch (SQLException e) { e.printStackTrace(); } examVo.setSid(sNum); examVo.setSname(sName); examVo.setClassExam(classExam); } /** * 根据科目修改成绩 查询学号 姓名 成绩 后修改成绩 * */ public void UpdateClassStuName() { // int i = 0; PreparedStatement ps = null; ResultSet rs = null; int j = getnumberBySelectClassName( DBSql.SELECT_CLASS_STU_SNO_SNAME_EXAM_COUNT, examVo.getC_id()); try { ps = conn.prepareStatement(DBSql.UPDATE_CHIVEMENT_BY_CLASS); for(int i =0;i<j;i++){ ps.setInt(1, examVo.getClassExam()[i]); ps.setInt(2, examVo.getSid()[i]); ps.setInt(3, examVo.getC_id()); ps.executeUpdate(); } } catch (SQLException e) { e.printStackTrace(); } } /** * 全部查询获得行数 * * @return */ public int getnumberAll(String str) { int number = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(str); rs = ps.executeQuery(); rs.next(); number = rs.getInt(1); // rs.close(); // ps.close(); // conn.close(); } catch (SQLException e) { e.printStackTrace(); } return number; } /** * 根据学号 根据组号 根据课程号查询 获得行数 * * @return */ public int getnumber(String str, int i) { int number = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(str); ps.setInt(1, i); rs = ps.executeQuery(); rs.next(); number = rs.getInt(1); // rs.close(); // ps.close(); // conn.close(); } catch (SQLException e) { e.printStackTrace(); } return number; } /** * 根据姓名 课程名 查询 获得行数 * */ public int getnumberByName(String str, String i) { int number = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(str); ps.setString(1, i); ps.setString(2, "%" + i + "%"); ps.setString(3, "%" + i); ps.setString(4, i + "%"); rs = ps.executeQuery(); rs.next(); number = rs.getInt(1); } catch (SQLException e) { e.printStackTrace(); } return number; } // /** // * 根据课程名查询 获得行数 // * // */ // // public int getnumberByClassName(String str, String i) { // int number = 0; // PreparedStatement ps = null; // ResultSet rs = null; // try { // ps = conn.prepareStatement(str); // ps.setString(1, i); // ps.setString(2, "%" + i + "%"); // ps.setString(3, "%" + i); // ps.setString(4, i + "%"); // rs = ps.executeQuery(); // rs.next(); // number = rs.getInt(1); // } catch (SQLException e) { // e.printStackTrace(); // } // return number; // } /** * * 根据课程名修改成绩获得行数 * * @param str * @param i * @return */ public int getnumberBySelectClassName(String str, int i) { int number = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(str); ps.setInt(1, i); rs = ps.executeQuery(); rs.next(); number = rs.getInt(1); } catch (SQLException e) { e.printStackTrace(); } return number; } }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值