java数据库管理系统课程设计学生信息管理系统

上传人:沈*** 文档编号:82417954 上传时间:2022-04-29 格式:DOC 页数:16 大小:128KB
收藏 版权申诉 举报 下载
java数据库管理系统课程设计学生信息管理系统_第1页
第1页 / 共16页
java数据库管理系统课程设计学生信息管理系统_第2页
第2页 / 共16页
java数据库管理系统课程设计学生信息管理系统_第3页
第3页 / 共16页
资源描述:

《java数据库管理系统课程设计学生信息管理系统》由会员分享,可在线阅读,更多相关《java数据库管理系统课程设计学生信息管理系统(16页珍藏版)》请在装配图网上搜索。

1、Java课程设计姓 名:学 号:班 级:学 院:指导教师:目录1. 题目简介2. 程序概要.3. 程序函数简介.4. 源代码5. 运行截图.6. 心得体会.1题目简介题目简介:要求基于数据库管理系统,建立一个学生信息管理系统,有简单的显示、更新、插入等基本功能。还有程序需有窗口,也就是运行界面中要含有窗口。程序尽量简单,但功能得全面,界面做到尽善尽美!2.程序概要程序概要:本程序中含有一个public类,三个一般类。其主函数在public类中,一般类中每个类实现一个功能。在主函数中调用一般类中的函数,实现不同的功能。每个一般类也是建立在窗口上的,其中运用了窗口,组件,按钮,布局等多种知识。3.

2、程序函数简介public static void main(String args ).主函数class DatabaseWin extends JFrame implements ActionListener该类实现主要窗口的建立DatabaseWin().建立窗口,添加窗口组件public void actionPerformed(ActionEvent e).实现监视class InsertRecord extends JDialog implements ActionListener负责插入的类InsertRecord(String s)实现插入功能class ShowRecord e

3、xtends JDialog implements ActionListener负责显示的类ShowRecord(String title).实现显示功能class ModifyRecord extends JDialog implements ActionListener.责更新的类ModifyRecord(String s).实现更新功能4.源代码import javax.swing.*; import java.awt.*;import java.awt.event.*;import java.sql.*;import javax.swing.border.*;public class

4、Mykcsj public static void main(String args ) try Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); catch(ClassNotFoundException e) System.out.println(+e); DatabaseWin win=new DatabaseWin(); class DatabaseWin extends JFrame implements ActionListener/主窗口 JMenuBar menubar; JMenu menu; JMenuItem itemShow,ite

5、mUpdate,itemInsert; ShowRecord showRecord; ModifyRecord modifyRecord; InsertRecord insertRecord; DatabaseWin() menubar=new JMenuBar(); menu=new JMenu(操作数据库); itemShow=new JMenuItem(显示记录); itemUpdate=new JMenuItem(更新记录); itemInsert=new JMenuItem(插入记录); itemShow.addActionListener(this); itemUpdate.add

6、ActionListener(this); itemInsert.addActionListener(this); menu.add(itemShow); menu.add(itemUpdate); menu.add(itemInsert); menubar.add(menu); showRecord=new ShowRecord(显示记录对话框); modifyRecord=new ModifyRecord(修改记录对话框); insertRecord=new InsertRecord(插入记录对话框); setJMenuBar(menubar); setBounds(100,100,370

7、,250); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); public void actionPerformed(ActionEvent e) if(e.getSource()=itemShow) showRecord.setVisible(true); else if(e.getSource()=itemUpdate) modifyRecord.setVisible(true); else if(e.getSource()=itemInsert) insertRecord.setVisible(true)

8、; class InsertRecord extends JDialog implements ActionListener /负责插入记录的类 JLabel hintLabel; Object name=学号,姓名,出生日期,身高; Object a=new Object14; JTable table; JButton enterInsert; Connection con; Statement sql; ResultSet rs; String num; InsertRecord(String s) setTitle(s); hintLabel=new JLabel(输入新记录:); t

9、able=new JTable(a,name); enterInsert=new JButton(插入新记录); setLayout(null); Box baseBox=Box.createHorizontalBox(); baseBox.add(hintLabel); baseBox.add(new JScrollPane(table); baseBox.add(enterInsert); add(baseBox); baseBox.setBounds(10,40,600,38); enterInsert.addActionListener(this); setBounds(120,160

10、,700,200); public void actionPerformed(ActionEvent e) try con=DriverManager.getConnection(jdbc:odbc:hello,); sql=con.createStatement(); int k=sql.executeUpdate (INSERT INTO message VALUES(+ a00+,+a01+,+a02+,+a03+); if(k=1) JOptionPane.showMessageDialog (this,插入记录成功,成功,JOptionPane.PLAIN_MESSAGE); con

11、.close(); catch(SQLException ee) JOptionPane.showMessageDialog (this,插入记录失败+ee,失败,JOptionPane.ERROR_MESSAGE); class ShowRecord extends JDialog implements ActionListener/负责显示记录的类 JTable table; Object a; Object name=学号,姓名,出生日期,身高; JButton showRecord; Connection con; Statement sql; ResultSet rs; ShowRe

12、cord(String title) setTitle(title); showRecord=new JButton(显示记录); showRecord.addActionListener(this); add(showRecord,BorderLayout.NORTH); setBounds(200,60,400,250); public void actionPerformed(ActionEvent e) try con=DriverManager.getConnection(jdbc:odbc:hello,); sql=con.createStatement (ResultSet.TY

13、PE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY); rs=sql.executeQuery(SELECT * FROM message ); rs.last(); int lastNumber=rs.getRow(); a=new ObjectlastNumber4; int k=0; rs.beforeFirst(); while(rs.next() ak0=rs.getString(1); ak1=rs.getString(2); ak2=rs.getDate(3); ak3=rs.getString(4); k+; con.close();

14、catch(SQLException ee) System.out.println(ee); table=new JTable(a,name); getContentPane().removeAll(); validate(); add(showRecord,BorderLayout.NORTH); add(new JScrollPane(table),BorderLayout.CENTER); validate(); class ModifyRecord extends JDialog implements ActionListener /负责更新记录的类 JLabel hintLabel;

15、 JTextField inputNumber; Object name=姓名,出生日期,身高; Object a=new Object13; JTable table; JButton enterModify; Connection con; Statement sql; ResultSet rs; String num; ModifyRecord(String s) setTitle(s); hintLabel=new JLabel(输入学号(回车确认):); inputNumber=new JTextField(20); table=new JTable(a,name); enterMo

16、dify=new JButton(更新记录); setLayout(null); Box baseBox=Box.createHorizontalBox(); baseBox.add(hintLabel); baseBox.add(inputNumber); baseBox.add(new JScrollPane(table); baseBox.add(enterModify); add(baseBox); baseBox.setBounds(10,40,600,38); inputNumber.addActionListener(this); enterModify.addActionLis

17、tener(this); setBounds(20,60,700,200); public void actionPerformed(ActionEvent e) if(e.getSource()=inputNumber) try num=inputNumber.getText().trim(); con=DriverManager.getConnection(jdbc:odbc:hello,); sql=con.createStatement(); rs=sql.executeQuery(SELECT * FROM message WHERE 学号=+num+); boolean boo=r

18、s.next(); if(boo=false) JOptionPane.showMessageDialog (this,学号不存在,提示,JOptionPane.WARNING_MESSAGE); else a00=rs.getString(2); a01=rs.getDate(3).toString(); a02=rs.getString(4); table.repaint(); con.close(); catch(SQLException ee) System.out.println(ee); if(e.getSource()=enterModify) try con=DriverMan

19、ager.getConnection(jdbc:odbc:hello,); sql=con.createStatement(); sql.executeUpdate (UPDATE message SET 姓名=+a00+ ,出生日期=+a01+ ,身高=+a02+WHERE 学号=+num+); JOptionPane.showMessageDialog (this,更新成功,成功,JOptionPane.PLAIN_MESSAGE); con.close(); catch(SQLException ee) JOptionPane.showMessageDialog (this,更新失败+ee,失败,JOptionPane.ERROR_MESSAGE); 5.运行截图插入前:插入后:更新前:更新后:7. 设计心得其实这次课程设计相对于前几次的课程设计相对容易的多,因为我们刚学完就开始做这个,所以很多东西都很清楚。但是作为一个课程设计,也有很多难点。刚开始写的时候很顺利,但随着功能得加大,越来越多的东西需要我去查资料,问同学,问老师。这次课程设计大概耗时半个月,设计结果自己还算满意。这次课程设计虽然花了很多时间,但也学到了很多东西。这就是课程设计的目的,我想我已经做到,也已经深深体会到了.

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!