1、设计数据库课程设计Java实现一、课程设计目的 在数据库原理课程基础上,培养学生综合运用数据库知识的能力。学会数据库的设计、规划以及应用程序的开发和调试,使学生掌握客户机/服务器体系结构,学会大型数据库的工作模式。大型数据库管理系统存放于服务器,数据库放在服务器上,学生在客户机上开发应用程序访问服务器上的数据库,并完成应用系统所要求的各项功能,应用程序的开发需要采用当前流行的新软件。二、课程设计内容1 数据库的设计根据学生信息管理系统,经过调查研究,构建合理的数据库。首先构建基本表以及表和表之间的联系,在此基础上构建视图和索引表。2 服务器的组织根据建立的基本表、视图和索引表搭建服务器。3 前
2、端开发工具:java学习并完成编写程序。服务器端:SQL Server20124 开发应用程序利用所学的新软件开发工具进行应用程序的开发。5 连接、调试。 三、软硬件环境及系统所采用的体系结构系统的体系结构为C/S结构,具体开发工具为Ecplise ,前台为Java,后台数据库一般为SQL Server2012。四、需求分析通过对学生信息管理的了解,确定本系统具备一下功能。多用户账号登录只要通过用户登录验证后,能对学生的记录信息进行修改,增加,删除等操作。五、系统设计 1系统结构图a.功能模块图查看学科成绩 查询 增加选课 修改 删除选课2数据库设计学生包含的信息: N MLogin表USE
3、StudentGOSET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE TABLE dbo.Login( userName nvarchar(20) NOT NULL, password nvarchar(10) NULL, CONSTRAINT PK_Login PRIMARY KEY CLUSTERED ( userName ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PA
4、GE_LOCKS = ON) ON PRIMARY) ON PRIMARYGOStudentIfor表USE StudentGOSET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE TABLE dbo.StudentIfor( code nvarchar(10) NOT NULL, name nvarchar(10) NOT NULL, sex nchar(2) NOT NULL, room nvarchar(10) NOT NULL, address nvarchar(50) NULL, tel nvarchar(11) NULL, CONS
5、TRAINT PK_StudentInfor PRIMARY KEY CLUSTERED ( code ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON PRIMARY) ON PRIMARYGOCrouse表CREATE TABLE dbo.Course( courseID nchar(5) NOT NULL, courseName nvarchar(40) NOT NULL, CONSTR
6、AINT PK_Course PRIMARY KEY CLUSTERED ( courseID ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON PRIMARY) ON PRIMARYGOStudent_Crouse表CREATE TABLE dbo.Student_Course( code nvarchar(10) NOT NULL, courseID nchar(5) NOT NULL,
7、courseGrade float NULL, CONSTRAINT PK_Student_Course PRIMARY KEY CLUSTERED ( code ASC, courseID ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON PRIMARY) ON PRIMARYGO六、系统的实施系统的实现方法是用java结合SqlServer2012,用java编写前端的用户界面主要的界面代
8、码如下:public class windows implements ActionListener private JFrame frame; private JLabel label; private JTextField textField; private JList list; private JScrollPane jscrollPane; private DefaultListModel listModel; private JRadioButton mjRadioButton, fjRadioButton; private ButtonGroup setButtonGrop;
9、private JButton button; private JButton jbu; private Container con; private ResultSet resultSet; private String sinfor = * 学号:,* 姓名:,* 性别:,*宿舍:,住址:,电话:; private String binfor = 增加,删除,修改,查找,上一条,下一条; public windows() frame = new JFrame(学生信息管理 ); con = frame.getContentPane(); con.setLayout(null); frame
10、.setLocation(350, 150); frame.setSize(7770/15, 6000/15); frame.setResizable(false); textField = new JTextField6; label = new JLabel6; button = new JButton6; for(int i = 0; i 6; i+) labeli = new JLabel(sinfori); labeli.setLocation(5, 3 + (i * 670/15); labeli.setSize(570/15, 670/15); con.add(labeli);
11、if(i != 2) textFieldi = new JTextField(); textFieldi.setSize(200, 470/15); textFieldi.setLocation(770/15,5 +(i * 670/15); con.add(textFieldi); else mjRadioButton = new JRadioButton(男,false); mjRadioButton.setVisible(true); mjRadioButton.setSize(570/15, 670/15); mjRadioButton.setLocation(970/15,5 + (
12、2 * 670/15); mjRadioButton.addActionListener(this); mjRadioButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR); fjRadioButton = new JRadioButton(女,false); fjRadioButton.setSize(570/15, 670/15); fjRadioButton.setLocation(2070/15,5 + (2 * 670/15); fjRadioButton.setCursor(Cursor.getPredefin
13、edCursor(Cursor.HAND_CURSOR); fjRadioButton.setVisible(true); fjRadioButton.addActionListener(this); setButtonGrop = new ButtonGroup(); setButtonGrop.add(mjRadioButton); setButtonGrop.add(fjRadioButton); con.add(mjRadioButton); con.add(fjRadioButton); buttoni = new JButton(binfori); buttoni.setSize(
14、1570/15,370/15); buttoni.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR); buttoni.addActionListener(this); if(i = 2) buttoni.setLocation(240/15 + (i * 2000/15),4300/15); else buttoni.setLocation(240/15 + (i-3)* 2000/15), 4300/15 + 450/15); con.add(buttoni); jbu = new JButton(查看成绩); jbu.setS
15、ize(1570/15, 800/15); jbu.setLocation(3 * 2000/15, 4300/15); jbu.addActionListener(this); con.add(jbu); select se = new select(); resultSet = se.selectTable(); listModel = new DefaultListModel(); try while(resultSet.next() listModel.addElement(resultSet.getString(code) + + resultSet.getString(name);
16、 catch (SQLException e) e.printStackTrace(); se.isDisconnection(); list = new JList(listModel); list.addMouseListener(new MouseAdapter() public void mouseClicked(MouseEvent e) if(e.getClickCount() = 2 & list.getSelectedIndex() != -1) clickTwo(list.getSelectedValue(); ); jscrollPane = new JScrollPane
17、(list); jscrollPane.setSize(200, 250); jscrollPane.setLocation(270, 7); con.add(jscrollPane); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 应用程序的编制方法是用户点击给出的功能按钮实现对应的功能,按钮响应中调用相应的类及方法,重要代码如下:private void clickTwo(Object value) String str = null; ResultSet re; select s
18、e; str = value.toString().substring(0, 8); str.trim(); se = new select(); re = se.selectCode(str); try textField0.setText( re.getString(code); textField1.setText(re.getString(name); if(re.getString(sex).equals(女 ) = true) fjRadioButton.setSelected(true); else mjRadioButton.setSelected(true); textFie
19、ld3.setText(re.getString(room); textField4.setText(re.getString(address); textField5.setText(re.getString(tel); catch (SQLException e) e.printStackTrace(); se.isDisconnection(); public void actionPerformed(ActionEvent e) String code = null, name = null, sex = , room = null, address =null, tel = null
20、; if(e.getSource() = button0) code = textField0.getText(); name = textField1.getText(); Enumeration en=setButtonGrop.getElements(); while(en.hasMoreElements() AbstractButton ab=en.nextElement(); if(ab.isSelected() sex = ab.getText(); room = textField3.getText(); address = textField4.getText(); tel =
21、 textField5.getText(); code.trim(); name.trim(); room.trim(); address.trim(); tel.trim(); if(code.equals()!= true & name.equals()!=true & room.equals()!=true & sex.equals()!= true) if(new addInfor(code, name, sex, address, room, tel).addToDataBase() = true) JOptionPane.showMessageDialog(frame, 增加成功)
22、; select se = new select(); resultSet = se.selectTable(); listModel = new DefaultListModel(); try while(resultSet.next() listModel.addElement(resultSet.getString(code) + + resultSet.getString(name); catch (SQLException e1) e1.printStackTrace(); list.setModel(listModel); se.isDisconnection(); for(int
23、 i = 0; i 6; i+) if(i != 2) textFieldi.setText(); else JOptionPane.showMessageDialog(frame, 增加失败,请核对信息); else JOptionPane.showMessageDialog(frame, 填入信息不全,请核对,警告,JOptionPane.WARNING_MESSAGE); if(e.getSource() = mjRadioButton | e.getSource() = fjRadioButton) sex = e.getActionCommand(); if(e.getSource(
24、) = button1) String deli = null; deli = JOptionPane.showInputDialog(frame, 请输入删除的学号:); if(deli != null) deli.trim(); if(deli.equals() != true) if(new deleteInfor(deli).studentDel() = true) JOptionPane.showMessageDialog(frame, 删除成功); select se = new select(); resultSet = se.selectTable(); listModel =
25、 new DefaultListModel(); try while(resultSet.next() listModel.addElement(resultSet.getString(code) + + resultSet.getString(name); catch (SQLException e1) e1.printStackTrace(); list.setModel(listModel); se.isDisconnection(); else JOptionPane.showMessageDialog(frame, 删除失败,请核对信息); else JOptionPane.show
26、MessageDialog(frame, 学号不能为空,错误,JOptionPane.ERROR_MESSAGE); if(e.getSource() = button2) code = textField0.getText(); name = textField1.getText(); Enumeration en=setButtonGrop.getElements(); while(en.hasMoreElements() AbstractButton ab=en.nextElement(); if(ab.isSelected() sex = ab.getText(); room = te
27、xtField3.getText(); address = textField4.getText(); tel = textField5.getText(); code.trim(); name.trim(); room.trim(); address.trim(); tel.trim(); if(code.equals()!= true & name.equals()!=true & room.equals()!=true & sex.equals()!= true) if(new update(code,name,sex,room,address,tel).updateStudentIfor() = true) JOptionPane.showMessageDialog(frame, 修改成功); select se = new select(); res
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1