ImageVerifierCode 换一换
格式:DOCX , 页数:15 ,大小:65.43KB ,
资源ID:8118033      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/8118033.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Java课程设计.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

Java课程设计.docx

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

2、上的,其中运用了窗口,组件,按钮,布局等多种知识。3.程序函数简介class ShowRecord extends JDialog implements ActionListener/负责显示记录的类class ModifyRecord extends JDialog implements ActionListener/负责更新记录的类class DeleteRecord extends JDialog implements ActionListener /负责删除记录的类class InsertRecord extends JDialog implements ActionListener

3、/负责插入记录的类public class Myku extends JFrame implements ActionListener主界面函数4.源代码import java.sql.*;import javax.swing.*;import java.awt.*;import java.awt.event.*;import javax.swing.border.*; class ShowRecord extends JDialog implements ActionListener/负责显示记录的类 JTable table; Object a; Object name=Name,Numb

4、er,Age,Sex,Degree; JButton showRecord; Connection con; Statement sql; ResultSet rs; ShowRecord(String title) setTitle(title); showRecord=new JButton(显示记录); showRecord.addActionListener(this); add(showRecord,BorderLayout.NORTH); setBounds(200,60,400,250); public void actionPerformed(ActionEvent e) tr

5、y con=DriverManager.getConnection(jdbc:odbc:hh,); sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY); rs=sql.executeQuery(SELECT * FROM StudentInformation); rs.last(); int lastNumber=rs.getRow(); a=new ObjectlastNumber5; int k=0; rs.beforeFirst(); while(rs.next() ak0

6、=rs.getString(1); ak1=rs.getLong(2); ak2=rs.getLong(3); ak3=rs.getString(4); ak4=rs.getLong(5); k+; con.close(); catch(SQLException ee) System.out.println(ee); table=new JTable(a,name); getContentPane().removeAll(); add(showRecord,BorderLayout.NORTH); add(new JScrollPane(table),BorderLayout.CENTER);

7、 validate(); class ModifyRecord extends JDialog implements ActionListener /负责更新记录的类 JLabel hintLabel,hintLabel1; JTextField inputName; JTextField inputNumber,inputAge,inputSex,inputDegree; Object name=Number,Age,Sex,Degree; Object a=new Object14; JTable table; JButton enterModify; Connection con; St

8、atement sql; ResultSet rs; String name3, number,age,sex,degree; ModifyRecord(String s) setTitle(s); hintLabel=new JLabel(输入姓名(回车确认):); hintLabel1=new JLabel(输 入:); inputName=new JTextField(5); inputAge=new JTextField(5); inputNumber=new JTextField(5); inputDegree=new JTextField(5); inputSex=new JTex

9、tField(5); table=new JTable(a,name); enterModify=new JButton(更新记录); setLayout(null); Box baseBox=Box.createHorizontalBox(); Box box=Box.createHorizontalBox(); baseBox.add(hintLabel); baseBox.add(inputName); baseBox.add(new JScrollPane(table); box.add(hintLabel1);box.add(Box.createHorizontalStrut(100

10、); box.add(inputNumber); box.add(inputAge); box.add(inputSex); box.add(inputDegree); box.add(enterModify); add(baseBox,BorderLayout.NORTH); add(box,BorderLayout.CENTER); baseBox.setBounds(10,40,520,38); box.setBounds(10,100,580,38); inputName.addActionListener(this); enterModify.addActionListener(th

11、is); setBounds(20,60,700,200); System.out.println(gengxinjilu); public void actionPerformed(ActionEvent e) name3=inputName.getText().trim(); number=inputNumber.getText().trim(); age=inputAge.getText().trim(); sex=inputSex.getText().trim(); degree=inputDegree.getText().trim(); if(e.getSource()=inputN

12、ame) try con=DriverManager.getConnection(jdbc:odbc:hh,); sql=con.createStatement(); rs=sql.executeQuery(SELECT * FROM StudentInformation WHERE Name=+name3+); boolean boo=rs.next(); if(boo=false) JOptionPane.showMessageDialog (this,姓名不存在,提示,JOptionPane.WARNING_MESSAGE); else a00=rs.getLong(2); a01=rs

13、.getLong(3); a02=rs.getString(4); a03=rs.getLong(5); table.repaint(); con.close(); catch(SQLException ee) System.out.println(ee); if(e.getSource()=enterModify) try con=DriverManager.getConnection(jdbc:odbc:hh,); sql=con.createStatement(); sql.executeUpdate(UPDATE StudentInformation SET StudentInform

14、ation.Number=(+number+) WHERE Name=+name3+); sql.executeUpdate(UPDATE StudentInformation SET StudentInformation.Age=(+age+) WHERE Name=+name3+); sql.executeUpdate(UPDATE StudentInformation SET StudentInformation.Sex=(+sex+) WHERE Name=+name3+); sql.executeUpdate(UPDATE StudentInformation SET Student

15、Information.Degree=(+degree+) WHERE Name=+name3+); System.out.println(成功); JOptionPane.showMessageDialog(this,更新成功,成功,JOptionPane.PLAIN_MESSAGE); con.close(); catch(SQLException ea) JOptionPane.showMessageDialog (this,更新失败+ea,失败,JOptionPane.ERROR_MESSAGE); class InsertRecord extends JDialog implemen

16、ts ActionListener /负责插入记录的类 JLabel hintLabel; Object name=Name,Number,Age,Sex,Degree,; Object a=new Object15; JTable table; JButton enterInsert; Connection con; Statement sql; ResultSet rs; InsertRecord(String s) setTitle(s); hintLabel=new JLabel(输入新记录:); table=new JTable(a,name); enterInsert=new JB

17、utton(插入新记录); setLayout(null); Box baseBox=Box.createHorizontalBox(); baseBox.add(hintLabel); baseBox.add(new JScrollPane(table); baseBox.add(as); baseBox.add(enterInsert); add(baseBox); baseBox.setBounds(10,40,600,38); enterInsert.addActionListener(this); setBounds(120,160,700,200); public void act

18、ionPerformed(ActionEvent e) if(e.getSource()=enterInsert) table.requestFocus(); try con=DriverManager.getConnection(jdbc:odbc:hh,); sql=con.createStatement(); int k=sql.executeUpdate(INSERT INTO StudentInformation VALUES(+a00+,+a01+,+a02+,+a03+,+a04+); System.out.println(a04); if(k=1) JOptionPane.sh

19、owMessageDialog (this,插入记录成功,成功,JOptionPane.PLAIN_MESSAGE); con.close(); catch(SQLException ee) JOptionPane.showMessageDialog (this,插入记录失败+ee,失败,JOptionPane.ERROR_MESSAGE); class DeleteRecord extends JDialog implements ActionListener /负责删除记录的类 JLabel hintLabel; JTextField inputNumber; Object name=Nu

20、mber,Age,Sex,Degree; Object a=new Object14; JTable table; JButton delete; Connection con; Statement sql; ResultSet rs; String name2; DeleteRecord(String s) setTitle(s); hintLabel=new JLabel(删除记录); inputNumber=new JTextField(20); table=new JTable(a,name); delete=new JButton(删除); setLayout(null); Box

21、baseBox=Box.createHorizontalBox(); baseBox.add(hintLabel); baseBox.add(inputNumber); baseBox.add(new JScrollPane(table); baseBox.add(delete); add(baseBox); baseBox.setBounds(10,40,600,38); inputNumber.addActionListener(this); delete.addActionListener(this); setBounds(20,60,700,200); public void acti

22、onPerformed(ActionEvent e) if(e.getSource()=inputNumber) try name2=inputNumber.getText().trim(); con=DriverManager.getConnection(jdbc:odbc:hh,); sql=con.createStatement(); rs=sql.executeQuery(SELECT * FROM StudentInformation WHERE Name=+name2+); boolean boo=rs.next(); if(boo=false) JOptionPane.showM

23、essageDialog (this,姓名不存在,提示,JOptionPane.WARNING_MESSAGE); else a00=String.valueOf(rs.getLong(2); a01=String.valueOf(rs.getLong(3); a02=rs.getString(4); a03=String.valueOf(rs.getLong(5); table.repaint(); con.close(); catch(SQLException ee) System.out.println(ee); if(e.getSource()=delete) try con=Driv

24、erManager.getConnection(jdbc:odbc:hh,); sql=con.createStatement(); sql.executeUpdate(DELETE FROM StudentInformation WHERE Name=+name2+); JOptionPane.showMessageDialog (this,删除成功,成功,JOptionPane.PLAIN_MESSAGE); con.close(); catch(SQLException ee) JOptionPane.showMessageDialog (this,删除失败+ee,失败,JOptionP

25、ane.ERROR_MESSAGE); public class xinde extends JFrame implements ActionListener JButton Insert,Delete,Update,Show; JPanel ps; JTable table; Object a=new Object105; Object name=Name,Number,Age,Sex,Degree; Connection con; Statement sql; ResultSet rs; xinde() setTitle(数据库管理); Insert=new JButton(插入); De

26、lete=new JButton(删除); Update=new JButton(更新); Show=new JButton(刷新); Insert.addActionListener(this); Delete.addActionListener(this); Update.addActionListener(this); Show.addActionListener(this); ps=new JPanel(); ps.add(Show); ps.add(Insert); ps.add(Delete); ps.add(Update); add(ps,BorderLayout.SOUTH);

27、 tryClass.forName(sun.jdbc.odbc.JdbcOdbcDriver); catch(Exception ce) trycon=DriverManager.getConnection(jdbc:odbc:hh,); sql=con.createStatement(); rs=sql.executeQuery(SELECT * FROM StudentInformation order by Name); int k=0; while(rs.next() ak0=rs.getString(1); ak1=rs.getLong(2); ak2=rs.getLong(3);

28、ak3=rs.getString(4); ak4=rs.getLong(5); k+; con.close(); catch(Exception xe) table=new JTable(a,name); add(new JScrollPane(table),BorderLayout.CENTER); validate(); setBounds(500,250,600,250); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); public void actionPerformed(ActionEvent ae) if(ae.getSource()=Insert) InsertRecord INsert=new InsertRecord(插入数据); INsert.setVisible(true); if(ae.getSo

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1