




已阅读5页,还剩14页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
广东海洋大学 课程设计报告课程设计报告 课程名称Java 程序设计课程设计 时间2013 2014 学年第一学期 学院信息学院 所 在 系 计算机 指导教师甘元驹 班级计科 1111 学生姓名 学生学号2011116621126 目 录 2 一 项目说明 3 二 设计的思路和关键数据结构 3 三 在设计 实现和测试中发现的问题以及你的解决方案 4 四 测试 5 五 总结 6 六 程序代码 6 一 项目说明 Eclipse 是一个开放源代码的 基于 Java 的可扩展开发平台 就其 本身而言 它只是一个框架和一组服务 用于通过插件组件构建开发环境 幸 运的是 Eclipse 附带了一个标准的插件集 包括 Java 开发工具 Java Development Kit JDK 这种平等和一致性并不仅限于 Java 开发工具 尽管 Eclipse 是使用 Java 语言开发的 但它的用途并不限于 Java 语言 例如 支持诸如 C C COBOL PHP 等编程语言的插件已经可用 或预计将会推出 Eclipse 框架还可用来作为与软件开发无关的其他应用程序类型的基础 比如内容管理 系统 基于 Eclipse 的应用程序的一个突出例子是 IBM Rational Software Architect 它构成了 IBM Java 开发工具系列的基础 二 设计的思路和关键数据结构 实现功能 1 学生基本信息的增加 2 学生基本信息修改 3 学生基本信息删除 4 学生查询 对学生基本信息的查询 数据流图是在对系统分析调查的基础上 以系统的科学性 管理的合 理性 技术的可行性角度出发 将信息处理功能和彼此之间的联系自顶向下 逐层分解 从逻辑上精确地描述应具有的数据加工功能 数据输入 数据输出 数据存储及数据的来源和去向 学生信息管理系统经过划分出各子系统及其各 自的功能 以及相互联系 绘制出数据流图 学生基本信息 学生信息查询 学生信息修改 学生信息添加 学生信息删除 系统数据流图系统数据流图 处理逻辑的描述 处理逻辑名称 查询信息处理查询信息处理 简述 学生对自己的基本信息和成绩进行查询 输入的数据流 输出结果 处理描述 根据管理人员输出结果使用户可以查询所需要的信息 输出的数据流 输入请求 处理逻辑名称 添加 修改信息处理添加 修改信息处理 简述 通过请求结果对学生的基本信息和成绩进行添加 修改操作 输入的数据流 请求结果 处理描述 完善学生的基本信息和成绩的管理 使之更准确有效 处理逻辑名称 删除信息处理删除信息处理 简述 通过请求结果对学生的基本信息和成绩删除操作 输入的数据流 删除请求 处理描述 对于错误信息或者失效信息进行删除操作 输出的数据流 删除结果 处理逻辑名称 录入学生信息录入学生信息 简述 将学生的基本信息录入该系统 处理描述 对学生的信息进行录入 三 在设计 实现和测试中发现的问题以及你的解决方案 1 在设计和实现时 最重要的是如何连接数据库 以及数据库连接的释放 解决办法是 在连接完数据库之后就要释放连接 否则很多数据库连接没释放 会出现异常 2 考虑到学生信息的非常多 解决办法是 所以用分页的效果查询学生的 数据 很好的减少了内存的压力 3 考虑到可以在 excel 表格浏览 解决办法是 写代码实现学生信息导出 成 excel 表格 四 测试 修改数据 删除数据 成绩查询 五 总结 通过本次课程设计 不仅让我更深入的了解 JAVA 这门学科 更使自己有了 继续探索的兴趣 对我来说 在之前的学习过程中没有能够很好的掌握 JAVA 语言的学习 在 很多地方还有生疏和遗漏 并且在此次课程设计过程中也遇到困难不能自己独 立解决 但是 通过这次程序设计 除了增加了自己的编程能力 提高了我对 JAVA 的应用能力 同时我也深感 认真严谨 这个词的重要性 一点点小的马 虎 便会导致整个程序不能正常运行 在今后的学习中 我将继续保持严谨的 学习态度 与此同时 在同学的帮助下 让我体会到了相互学习的重要性 而 更让人难以忘怀的是在热烈讨论问题时 那激情横溢的场面 总之 此次课程 设计让我获益匪浅 六 程序代码 6 1 主类代码 主类代码 import javax swing import java awt import java awt event class MyPanel extends JPanel Image img Toolkit getDefaultToolkit getImage C Users Administrator Desktop 1360077313824 gif public void paint Graphics g g drawImage img 0 0 this public class MainForm extends JFrame implements ActionListener 继承 JFrame 窗口类实 现 ActionListener JMenu mSystem new JMenu 系统 菜单 JMenuItem mExit new JMenuItem 退出 JMenu mOperate new JMenu 数据操作 JMenuItem mAdd new JMenuItem 添加 JMenuItem mDel new JMenuItem 删除 JMenuItem mModify new JMenuItem 修改 JMenu mQuery new JMenu 查询 JMenuItem mName new JMenuItem 按姓名查询 JMenuItem mScore new JMenuItem 按成绩查询 JMenu mHelp new JMenu 帮助 JMenuItem mAbout new JMenuItem 软件信息 JMenuBar mBar new JMenuBar MainForm super 学生成绩管理系统 调用父类构造函数 setSize 875 583 mSystem add mExit mOperate add mAdd mOperate add mDel mOperate add mModify mQuery add mName mQuery add mScore mHelp add mAbout mBar add mSystem mBar add mOperate mBar add mQuery mBar add mHelp 添加控件 setJMenuBar mBar 菜单 mExit addActionListener this mAdd addActionListener this mDel addActionListener this mModify addActionListener this mName addActionListener this mScore addActionListener this 注册监听 mAbout addActionListener this setContentPane new MyPanel setVisible true public void actionPerformed ActionEvent ae 判断按钮点击事件 if ae getSource mExit System exit 0 else if ae getSource mAbout JOptionPane showMessageDialog this 学生成绩管理系统 n n 信息学院 n n 计科 1111 n n 许钦百 n n2013 年 12 月 软件信息 JOptionPane INFORMATION MESSAGE else if ae getSource mAdd new AddForm setVisible true else if ae getSource mDel new DeleteForm setVisible true else if ae getSource mModify new ModifyForm setVisible true else if ae getSource mName new NameQueryForm setVisible true else if ae getSource mScore new ScoreQueryForm setVisible true public static void main String args new MainForm 6 2 修改数据 修改数据 import javax swing import java awt import java awt event import java sql public class ModifyForm extends JFrame implements ActionListener JLabel labName new JLabel 姓名 JLabel labDate new JLabel 学号 JLabel labScore new JLabel 成绩 JTextField txtName new JTextField 20 JTextField txtDate new JTextField 18 JTextField txtScore new JTextField 20 JButton btnModify new JButton 修改 JButton btnCancel new JButton 取消 JButton btnQuery new JButton 查询 JPanel pan new JPanel JPanel pan1 new JPanel JPanel pan2 new JPanel JPanel pan3 new JPanel JPanel pan4 new JPanel Connection con Statement sql ResultSet rs ModifyForm super 修改数据 setSize 400 300 pan1 add labName pan1 add txtName pan2 add labDate pan2 add txtDate pan3 add labScore pan3 add txtScore pan4 add btnQuery pan4 add btnModify pan4 add btnCancel pan setLayout new GridLayout 3 1 pan add pan1 pan add pan2 pan add pan3 getContentPane add pan Center getContentPane add pan4 South btnQuery addActionListener this btnModify addActionListener this btnCancel addActionListener this btnModify setEnabled false txtDate setEditable false txtScore setEditable false setVisible true txtName requestFocus public void actionPerformed ActionEvent ae if ae getSource btnCancel dispose else if ae getSource btnQuery try Class forName net sourceforge jtds jdbc Driver catch ClassNotFoundException e try con DriverManager getConnection jdbc jtds sqlserver localhost 1433 学生成绩管理系统 user sa password 123 sql con createStatement rs sql executeQuery select from 成绩表 where 姓名 txtName getText if rs next txtName setText rs getString 姓名 txtScore setText new Integer rs getInt 成绩 toString txtDate setText rs getString 学号 toString btnModify setEnabled true txtDate setEditable true txtScore setEditable true else System out println 不存在该记录 btnModify setEnabled false txtName setText txtScore setText txtDate setText txtDate setEditable false txtScore setEditable false catch SQLException e else if ae getSource btnModify try System out println Update 成绩表 set 学号 txtDate getText 成绩 txtScore getText where 姓名 txtName getText sql executeUpdate Update 成绩表 set 学号 txtDate getText 成绩 txtScore getText where 姓名 txtName getText System out println 记录修改完毕 btnModify setEnabled false txtName setText txtScore setText txtDate setText txtDate setEditable false txtScore setEditable false con close catch SQLException e public static void main String args new ModifyForm 6 3 删除数据 删除数据 import javax swing import java awt import java awt event import java sql public class DeleteForm extends JFrame implements ActionListener JLabel labName new JLabel 姓名 JLabel labDate new JLabel 学号 JLabel labScore new JLabel 成绩 JTextField txtName new JTextField 20 JTextField txtDate new JTextField 18 JTextField txtScore new JTextField 20 JButton btnDelete new JButton 删除 JButton btnCancel new JButton 取消 JButton btnQuery new JButton 查询 JPanel pan new JPanel JPanel pan1 new JPanel JPanel pan2 new JPanel JPanel pan3 new JPanel JPanel pan4 new JPanel Connection con Statement sql ResultSet rs DeleteForm super 删除数据 setSize 400 300 pan1 add labName pan1 add txtName pan2 add labDate pan2 add txtDate pan3 add labScore pan3 add txtScore pan4 add btnQuery pan4 add btnDelete pan4 add btnCancel pan setLayout new GridLayout 3 1 pan add pan1 pan add pan2 pan add pan3 getContentPane add pan Center getContentPane add pan4 South btnQuery addActionListener this btnDelete addActionListener this btnCancel addActionListener this btnDelete setEnabled false 取消删除按钮的功能 txtDate setEditable false txtScore setEditable false setVisible true txtName requestFocus public void actionPerformed ActionEvent ae if ae getSource btnCancel dispose else if ae getSource btnQuery 实现查询功能 try Class forName net sourceforge jtds jdbc Driver catch ClassNotFoundException e try con DriverManager getConnection jdbc jtds sqlserver localhost 1433 学生成绩管理系统 user sa password 123 sql con createStatement rs sql executeQuery select from 成绩表 where 姓名 txtName getText if rs next txtName setText rs getString 姓名 txtScore setText new Integer rs getInt 成绩 toString txtDate setText rs getString 学号 toString btnDelete setEnabled true 使删除按钮功能实现 txtDate setEditable true txtScore setEditable true else System out println 不存在该记录 btnDelete setEnabled false txtName setText txtScore setText txtDate setText txtDate setEditable false txtScore setEditable false catch SQLException e else if ae getSource btnDelete 实现删除功能 try System out println Update 成绩表 set 学号 txtDate getText 成绩 txtScore getText where 姓名 txtName getText sql executeUpdate DELETE FROM 成绩表 where 姓名 txtName getText System out println 记录删除完毕 btnDelete setEnabled false txtName setText txtScore setText txtDate setText txtDate setEditable false txtScore setEditable false con close catch SQLException e public static void main String args new DeleteForm 6 4 添加数据 添加数据 import javax swing import java awt import java awt event import java sql public class AddForm extends JFrame implements ActionListener JLabel labName new JLabel 姓名 JLabel labDate new JLabel 学号 JLabel labScore new JLabel 成绩 JTextField txtName new JTextField 20 JTextField txtDate new JTextField 18 JTextField txtScore new JTextField 20 JButton btnAdd new JButton 添加 JButton btnCancel new JButton 取消 JPanel pan new JPanel JPanel pan1 new JPanel JPanel pan2 new JPanel JPanel pan3 new JPanel JPanel pan4 new JPanel Connection con Statement sql ResultSet rs AddForm super 添加数据 setSize 400 300 pan1 add labName pan1 add txtName pan2 add labDate pan2 add txtDate pan3 add labScore pan3 add txtScore pan4 add btnAdd pan4 add btnCancel pan setLayout new GridLayout 3 1 pan add pan1 pan add pan2 pan add pan3 getContentPane add pan Center getContentPane add pan4 South btnAdd addActionListener this btnCancel addActionListener this btnAdd setEnabled true txtDate setEditable true txtScore setEditable true setVisible true txtName requestFocus public void actionPerformed ActionEvent ae String recode insert1 学号 姓名 int 成绩 if ae getSource btnCancel this dispose else if ae getSource btnAdd try Class forName net sourceforge jtds jdbc Driver catch ClassNotFoundException e try con DriverManager getConnection jdbc jtds sqlserver localhost 1433 学生成绩管理系统 user sa password 123 sql con createStatement 姓名 txtName getText 学号 txtDate getText 成绩 Integer parseInt txtScore getText recode 姓名 学号 成绩 insert1 INSERT INTO 成绩表 VALUES recode sql executeUpdate insert1 System out println 记录添加完毕 btnAdd setEnabled false txtName setText txtScore setText txtDate setText con close catch SQLException e public static void main String args new AddForm 6 5 按姓名查询数据 按姓名查询数据 import javax swing import java awt import java awt event import java sql public class NameQueryForm extends JFrame implements ActionListener JLabel labName new JLabel 姓名 JLabel labDate new JLabel 学号 JLabel labScore new JLabel 成绩 JTextField txtName new JTextField 20 JTextField txtDate new JTextField 18 JTextField txtScore new JTextField 20 JButton btnCancel new JButton 取消 JButton btnQuery new JButton 查询 JPanel pan new JPanel JPanel pan1 new JPanel JPanel pan2 new JPanel JPanel pan3 new JPanel JPanel pan4 new JPanel Connection con Statement sql ResultSet rs NameQueryForm super 按姓名查询 setSize 400 300 pan1 add labName pan1 add txtName pan2 add labDate pan2 add txtDate pan3 add labScore pan3 add txtScore pan4 add btnQuery pan4 add btnCancel pan setLayout new GridLayout 3 1 pan add pan1 pan add pan2 pan add pan3 getContentPane add pan Center getContentPane add pan4 South btnQuery addActionListener this btnCancel addActionListener this txtDate setEditable false txtScore setEditable false setVisible true txtName requestFocus public void actionPerformed ActionEvent ae if ae getSource btnCancel dispose else if ae getSource btnQuery try Class forName net sourceforge jtds jdbc Driver catch ClassNotFoundException e try con DriverManager getConnection jdbc jtds sqlserver localhost 1433 学生成绩管理系统 user sa password 123 sql con createStatement rs sql executeQuery select from 成绩表 where 姓名 txtName getText if rs next txtName setText rs getString 姓名 txtScore setText new Integer rs getInt 成绩 toString txtDate setText rs getString 学号 toString else System out println 不存在该记录 txtName setText txtScore setText txtDate setText txtName requestFocus catch SQLException e public static void main String args new NameQueryForm 6 6 按成绩查询数据 按成绩查询数据 import javax swing import java awt import java awt event import java sql import javax swing table DefaultTableModel import javax swing table JTableHeader public class ScoreQueryForm extends JFrame implements ActionListener JLabel labScore new JLabel 请输入成绩 JTextField txtScore new JTextField 10 JButton btnQuery new JButton 查询 JPanel pan1 new JPanel JPanel pan2 new JPanel String str 姓名 学号 成绩 Object data new Object 10 3 JTable table new JTable data str JTableHeader head table getTableHeader JScrollPane jsp new JScrollPane table 滚动 Connection con Statement sql Resu
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 飞机模线样板移型工多工种协调能力考核试卷及答案
- 三方协议书有偿
- 公司汽车维修工职业健康技术规程
- 药芯焊丝成型工数字化转型工具应用考核试卷及答案
- 锚链打包浸漆工协作配合积极性考核试卷及答案
- 铸造造型(芯)工6S现场管理考核试卷及答案
- 公司感光材料涂布工岗位现场作业技术规程
- 公司茶园管理员工艺技术规程
- 福建省泉州第十六中学2026届七年级数学第一学期期末检测试题含解析
- 2025合同模板个人房屋租赁合同示范文本范本
- 2025年度社区工作者真题题库及答案
- 2025年9月 基孔肯雅热疫情防控工作的经验总结报告
- 鞘内药物输注技术
- 基层应急管理培训课件
- 乡镇卫生院管理制度
- 抗肿瘤药项目建议书(立项报告)
- 2024-2025学年山东省济南市高一上册第一次月考数学学情检测试题
- 二零二五年度版学校合作协议范本:高校与中小学合作培养协议
- 23G409先张法预应力混凝土管桩
- 《水的组成说课课案》课件
- 快件处理员(中级)职业技能鉴定考试题库(含答案)
评论
0/150
提交评论