云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > JAVA课程设计,基于mysql的学生信息管理系统

JAVA课程设计,基于mysql的学生信息管理系统

  • 62 次阅读
  • 3 次下载
  • 2025/6/2 1:11:33

JAVA课程设计

try {

sta = con.createStatement();

rs = sta.executeQuery(\ //从表depart中查询

所有数据

}

public Student findOne(int id){

Student student = new Student();

Connection con = DbConnection.getConnection();

21

while(rs.next()){ } rs.close(); sta.close();

Student student = new Student(); student.setId(rs.getInt(1)); student.setName(rs.getString(2)); student.setSex(rs.getString(3)); student.setBorn_date(rs.getString(4)); student.setDepart_id(rs.getString(5)); student.setClass_name(rs.getString(6));

System.out.println(student.getName()); students.add(student);

} catch (SQLException e) {

// TODO Auto-generated catch block e.printStackTrace();

}finally{ }

return students;

DbConnection.closeConnection(con);

JAVA课程设计

PreparedStatement ps; String sql = \ResultSet rs; try {

sql = \ps = con.prepareStatement(sql); ps.setInt(1, id);

rs = ps.executeQuery(); if(rs.next()){

student.setId(rs.getInt(\ //注意数据类型要对应 student.setName(rs.getString(\student.setSex(rs.getString(\

student.setBorn_date(rs.getString(\student.setDepart_id(rs.getString(\student.setClass_name(rs.getString(\System.out.println(\

//从表depart中查询所有数据

name:\

}

22

}else{ } rs.close(); ps.close();

System.out.println(\没有数据\

} catch (SQLException e) {

// TODO Auto-generated catch block e.printStackTrace();

}finally{ }

return student;

DbConnection.closeConnection(con);

JAVA课程设计

public boolean deleteInfo(Student student){

}

boolean flag;

Connection con = DbConnection.getConnection(); PreparedStatement ps; String sql = \try {

sql = \ id=?\用问号代替 ps = con.prepareStatement(sql); ps.setInt(1, student.getId()); ps.execute();

System.out.println(\成功删除了一条记录\

flag = true;

} catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace();

flag = false;

}finally{ DbConnection.closeConnection(con);

} return flag;

23

}

JAVA课程设计

三、 欢迎界面(Welcome.java)

package menu;

import java.awt.BorderLayout; import java.awt.Font; import java.awt.GridLayout;

import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.*; public class Welcome { JFrame w = new JFrame(\ JPanel p1 = new JPanel();

JPanel p2 = new JPanel();

JLabel l = new JLabel(\欢迎进入学生信息管理系统!\ JButton b = new JButton(\确定\ Welcome(){

w.addWindowListener(new Wind()); b.addMouseListener(new Monitor2());

Font font = new Font( \欢迎进入学生信息管理系统!\ l.setFont(font);

w.add(p1,BorderLayout.CENTER); w.add(p2,BorderLayout.SOUTH); p1.add(l);

l.setBounds(p1.WIDTH/2-100,p1.HEIGHT/2-10,200,20); p2.add(b);

b.setBounds(p2.WIDTH/2-10,p2.HEIGHT/2-6,20,12); w.setBounds(400, 200, 600, 200);

w.setVisible(true);

}

private class Monitor2 extends MouseAdapter{ public void mousePressed(MouseEvent e) { new Menu();

w.setVisible(false);

} } public static void main(String args[]){ new Welcome();

}

24

  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

JAVA课程设计 try { sta = con.createStatement(); rs = sta.executeQuery(\ //从表depart中查询所有数据 } public Student findOne(int id){ Student student = new Student(); Connection con = DbConnection.getConnection(); 21 while(rs.next()){ } r

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com