课程设计论文基于java实现昆虫科普信息设计.doc

上传人:sccc 文档编号:4868795 上传时间:2023-05-20 格式:DOC 页数:26 大小:1.91MB
返回 下载 相关 举报
课程设计论文基于java实现昆虫科普信息设计.doc_第1页
第1页 / 共26页
课程设计论文基于java实现昆虫科普信息设计.doc_第2页
第2页 / 共26页
课程设计论文基于java实现昆虫科普信息设计.doc_第3页
第3页 / 共26页
课程设计论文基于java实现昆虫科普信息设计.doc_第4页
第4页 / 共26页
课程设计论文基于java实现昆虫科普信息设计.doc_第5页
第5页 / 共26页
点击查看更多>>
资源描述

《课程设计论文基于java实现昆虫科普信息设计.doc》由会员分享,可在线阅读,更多相关《课程设计论文基于java实现昆虫科普信息设计.doc(26页珍藏版)》请在三一办公上搜索。

1、数据库课程设计论文一 需求分析11.1.用户需求:11.2.系统功能需求:11.3系统性能需求11.4系统软硬件环境确定1二 系统功能设计22.1系统功能结构22.2系统功能处理流程2三 系统数据库设计33.1数据库概念设计(E-R图)33.1.1用户表(users)33.1.2管理员表(admin)33.1.3 昆虫简介(summary)33.1.4昆虫信息(insect)33.2数据库逻辑设计43.3数据库物理设计43.3.1管理员(admin)43.3.2用户表(users)53.3.3昆虫纲目表(summary)53.3.4昆虫信息(insect)5四、系统实现54.1数据库连接的实现

2、54.2用户登录功能的实现64.3用户可以查看昆虫的分类以及纲目的简介功能的实现124.4用户查询,添加,更新以及清空功能的实现134.5管理员删除能的实现22五 总结24一 需求分析1.1.用户需求:为了增强同学们对昆虫的认识,使同学们对生活中的昆虫有一个更好的了解,现决定完成此昆虫科普信息系统。1.2.系统功能需求: 1).列出昆虫纲的几大目,并做简介;2).查询功能:输入昆虫名字,可以查询该昆虫的信息;3).更新功能:可以新添昆虫的种类;4).删除功能:可以删除昆虫的信息;5).修改功能:可以修改昆虫的信息;1.3系统性能需求能够对系统进行定期维护,对用户表只能进行添加注册,昆虫表可以进

3、行修改删除,科目表则只能进行在程序中显示。1.4系统软硬件环境确定软件:运用java语言,通过jdbc桥接mysql,使用lomboz eclipse为开发环境。硬件:主存2G,硬盘存储10运行环境:windows xp及以上系统。24二 系统功能设计2.1系统功能结构1).欢迎界面:包括菜单栏和“进入昆虫世界”的按钮;2).登录:点击菜单栏和右下角的“进入昆虫世界”按钮均为登录,需要输入用户名才可进行登录;3).科目简介:包括昆虫纲的总结介绍,昆虫纲一下所属目的介绍;4).菜单栏编辑:可以通过菜单栏进入对昆虫信息的查看(包括的昆虫的名字,分布,简介以及所属科目),查找(通过昆虫名字进行搜索)

4、,添加(新昆虫的信息)以及删除(需要登录超级管理员权限);用户登录2.2系统功能处理流程增加修改修 改信息普通用户超级管理员昆虫查询删除 昆虫信息三 系统数据库设计3.1数据库概念设计(E-R图)用户名3.1.1用户表(users)用户密码用户管理员3.1.2管理员表(admin)密码名称3.1.3 昆虫简介(summary)昆虫纲科目简介名称3.1.4昆虫信息(insect)分布名称信息科目介绍3.2数据库逻辑设计昆虫纲信息昆虫科目昆虫信息用户管理员只有管理员才能删除昆虫信息昆虫纲总纲信息昆虫科目信息用户名称用户密码注册名称分布所属科目介绍3.3数据库物理设计3.3.1管理员(admin)此

5、表存储管理员的登陆信息。 物理结构为:3.3.2用户表(users) 此表存储用户登录的信息。 物理结构为:3.3.3昆虫纲目表(summary)此表存储昆虫纲目的基本信息。物理结构为:3.3.4昆虫信息(insect)此表存储各种昆虫的详细信息。物理结构为:四、系统实现4.1数据库连接的实现public static Connection getConn() Connection conn = null;try Class.forName(com.mysql.jdbc.Driver);conn = DriverManager.getConnection(jdbc:mysql:/localho

6、st/insect_system?user=root&password=root); catch (ClassNotFoundException e) e.printStackTrace(); catch (SQLException e) e.printStackTrace();return conn;4.2用户登录功能的实现用户通过该窗体进行登陆,首先输入用户名与密码,通过在数据库中的users表中进行查询是否有此用户名,输入正确则进入系统,否则无反应。用户登录分为普通用户和管理员登录,删除时候需要管理员登录。另外普通用户可进行注册。用户登陆:用户注册:经理登陆:用户注册代码:public

7、class UserReg extends JFrameprivate static final long serialVersionUID = 1L;/* * 用户注册 */static JCoolButton creg =new JCoolButton();static JTextArea areg =new JTextArea();static JPasswordField alog =new JPasswordField();static JLabel treg = new JLabel();static JLabel tlog = new JLabel();public void l

8、aunchFrame()JPanel jp = new JPanel();jp.setLayout(null);jp.setBackground(Color.LIGHT_GRAY);setTitle(用户注册);setLocation(428, 250);setSize(320, 240);setVisible(true);treg.setText(用户名:);treg.setBounds(30, 40, 100, 20);tlog.setText(密码:);tlog.setBounds(30, 90, 100, 20);areg.setBounds(110, 40, 150, 20);alo

9、g.setBounds(110, 90, 150, 20);creg.setBounds(150, 160, 100, 20);creg.setText(确定);creg.addActionListener(new ActionListener()SuppressWarnings(deprecation)public void actionPerformed(ActionEvent arg0) String getid = areg.getText();String getsecret = alog.getText();DB.save(getid, getsecret);dispose();)

10、;jp.add(treg);jp.add(tlog);jp.add(areg);jp.add(alog);jp.add(creg);this.add(jp);用户登录代码:public class UserLogin extends JFrame private static final long serialVersionUID = 1L;/* * 用户登陆 */static JCoolButton creg = new JCoolButton();static JCoolButton clog = new JCoolButton();static JTextArea areg = new

11、JTextArea();static JPasswordField alog = new JPasswordField();static JLabel treg = new JLabel();static JLabel tlog = new JLabel();public void launchFrame() JPanel jp = new JPanel();jp.setLayout(null);jp.setBackground(Color.LIGHT_GRAY);setTitle(用户登陆);setLocation(428, 250);setSize(320, 240);setVisible

12、(true);treg.setText(用户名:);treg.setBounds(30, 40, 100, 20);tlog.setText(密码:);tlog.setBounds(30, 90, 100, 20);areg.setBounds(110, 40, 150, 20);alog.setBounds(110, 90, 150, 20);creg.setBounds(40, 160, 100, 20);creg.setText(注册);creg.addActionListener(new ActionListener() public void actionPerformed(Acti

13、onEvent e) new UserReg().launchFrame(););clog.setBounds(180, 160, 100, 20);clog.setText(登陆);clog.addActionListener(logAct);jp.add(treg);jp.add(tlog);jp.add(areg);jp.add(alog);jp.add(creg);jp.add(clog);this.add(jp);private ActionListener logAct = new ActionListener() public void actionPerformed(Actio

14、nEvent e) String selename = areg.getText();String selesecret = alog.getText();if (DB.selectname(selesecret).equals(selename)& DB.selectsecret(selename).equals(selesecret) new Summary().launchFrame();dispose();管理员登录代码:public class SuperAdmin extends JFrame private static final long serialVersionUID =

15、 1L;/* * 用户登陆 */static JCoolButton clog = new JCoolButton();static JTextArea areg = new JTextArea();static JPasswordField alog = new JPasswordField();static JLabel treg = new JLabel();static JLabel tlog = new JLabel();public void launchFrame() JPanel jp = new JPanel();jp.setLayout(null);jp.setBackgr

16、ound(Color.LIGHT_GRAY);setTitle(管理员登陆);setLocation(428, 250);setSize(320, 240);setVisible(true);treg.setText(用户名:);treg.setBounds(30, 40, 100, 20);tlog.setText(密码:);tlog.setBounds(30, 90, 100, 20);areg.setBounds(110, 40, 150, 20);alog.setBounds(110, 90, 150, 20);clog.setBounds(180, 160, 100, 20);clo

17、g.setText(登陆);clog.addActionListener(logAct);jp.add(treg);jp.add(tlog);jp.add(areg);jp.add(alog);jp.add(clog);this.add(jp);private ActionListener logAct = new ActionListener() SuppressWarnings(deprecation)public void actionPerformed(ActionEvent e) String selename = areg.getText();String selesecret =

18、 alog.getText();if (selesecret.equals(admin)& selename.equals(admin) & DB.pri(selename) = 1) String getname = Edit.tname.getText();DB.dele(getname);SuperAdmin.this.dispose();4.3用户可以查看昆虫的分类以及纲目的简介功能的实现用户进入系统后,即看到昆虫纲的总简介以及所分的科目:点击科目即可看到科目的简介:例如蜻蜓目,且图片为对应的:4.4用户查询,添加,更新以及清空功能的实现输入昆虫名称虎甲:点击查询:点击清空后:添加昆虫

19、:添加前数据库:添加“蚂蚁信息”:数据库插入后:更新蚂蚁信息后:数据库添加代码:public static void save(String name,String distribution,String intro,String belong) Connection conn = DB.getConn();/ 数据库操作PreparedStatement prepstmt = null;try prepstmt = conn.prepareStatement(insert into insect values (?,?,?,?);prepstmt.setString(1, name);pre

20、pstmt.setString(2, distribution);prepstmt.setString(3, intro);prepstmt.setString(4, belong);prepstmt.executeUpdate(); catch (SQLException e1) e1.printStackTrace(); finally try if (conn != null) conn.close();conn = null;if (prepstmt != null) prepstmt.close();prepstmt = null; catch (final SQLException

21、 e) e.printStackTrace(); 数据库查询代码:public static inforBean sele(String name) inforBean infor = new inforBean(intro,distri,belong);Connection conn = DB.getConn();/ 数据库操作PreparedStatement prepstmt1 = null;PreparedStatement prepstmt2 = null;PreparedStatement prepstmt3 = null;ResultSet rs1 = null;ResultSe

22、t rs2 = null;ResultSet rs3 = null;String distribution = null;String introduction = null;String belong = null;try prepstmt1 = conn.prepareStatement(select distribution from insect where name = (?);prepstmt2 = conn.prepareStatement(select intro from insect where name = (?);prepstmt3 = conn.prepareStat

23、ement(select belong from insect where name = (?);prepstmt1.setString(1, name);prepstmt2.setString(1, name);prepstmt3.setString(1, name);rs1 = prepstmt1.executeQuery();rs2 = prepstmt2.executeQuery();rs3 = prepstmt3.executeQuery();while (rs1.next() distribution = rs1.getString(distribution);infor.setD

24、istri(distribution);while (rs2.next() introduction = rs2.getString(intro);infor.setIntro(introduction);while (rs3.next() belong = rs3.getString(belong);infor.setBelong(belong); catch (SQLException e1) e1.printStackTrace(); finally try if (conn != null) conn.close();conn = null;if (prepstmt1 != null)

25、 prepstmt1.close();prepstmt1 = null;if (prepstmt2 != null) prepstmt2.close();prepstmt2 = null;if (prepstmt3 != null) prepstmt3.close();prepstmt3 = null; catch (final SQLException e) e.printStackTrace();return infor;数据库清空代码:public ActionListener cleaAct = new ActionListener() public void actionPerfor

26、med(ActionEvent e) tname.setText();tbelong.setSelectedItem(半翅目);tdistribution.setText();tintro.setText();数据库更新代码:public static void upda(String name,String distribution,String intro,String belong) Connection conn = DB.getConn();/ 数据库操作Statement st = null;PreparedStatement prepstmt = null;try st = co

27、nn.createStatement();st.executeQuery(select * from insect where name = + name + );prepstmt = conn.prepareStatement(update insect set distribution = (?),intro = (?),belong = (?) where name = (?);prepstmt.setString(1, distribution);prepstmt.setString(2, intro);prepstmt.setString(3, belong);prepstmt.se

28、tString(4, name);prepstmt.executeUpdate(); catch (SQLException e1) e1.printStackTrace(); finally try if (conn != null) conn.close();conn = null;if (prepstmt != null) prepstmt.close();prepstmt = null; catch (final SQLException e) e.printStackTrace(); 4.5管理员删除能的实现 通过查找到蚂蚁的信息,删除刚才所添加的蚂蚁的信息,但删除之前必须登录管理员

29、权限:登陆即有删除功能,删除后需要清空,搜索蚂蚁的结果和数据库的结果:删除部分代码:public static void dele(String name)Connection conn = DB.getConn();/ 数据库操作PreparedStatement prepstmt = null;try prepstmt = conn.prepareStatement(delete from insect where name = (?);prepstmt.setString(1, name);prepstmt.executeUpdate(); catch (SQLException e1)

30、 e1.printStackTrace(); finally try if (conn != null) conn.close();conn = null;if (prepstmt != null) prepstmt.close();prepstmt = null; catch (final SQLException e) e.printStackTrace();五 总结通过此次的实验设计,让我把平时的学习知识和现实的实际编程结合在了一起。这几周一直在致力于此实验设计,但是仍然遇到了很多问题,有的花费了很长时间才解决,比如添加背景图,但是有的解决的也不是很好,比如数据库的用户的权限的问题,只能算是基本解决,有的甚至没有解决,比如更新和插入保存不能放到一个功能键上。 但是从这次实验上我真的学到了很多,也学会了自己解决问题通过网络的帮助,而通过同学的帮助以及帮同学解决问题更加让我体会到了团结合作的重要性,总之这次实验设计让我受益匪浅。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 建筑/施工/环境 > 农业报告


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号