1、设计数据库课程设计Java实现一、课程设计目 在数据库原理课程基础上,培养学生综合运用数据库知识能力。学会数据库设计、规划以及应用程序开发和调试,使学生掌握客户机/服务器体系结构,学会大型数据库工作模式。大型数据库管理系统存放于服务器,数据库放在服务器上,学生在客户机上开发应用程序访问服务器上数据库,并完成应用系统所要求各项功能,应用程序开发需要采用当前流行新软件。二、课程设计内容1数据库设计根据学生信息管理系统,经过调查研究,构建合理数据库。首先构建基本表以及表和表之间联系,在此基础上构建视图和索引表。2服务器组织根据建立基本表、视图和索引表搭建服务器。3前端开发工具:java学习并完成编写
2、程序。服务器端:SQL Server20124开发应用程序利用所学新软件开发工具进行应用程序开发。5连接、调试。 三、软硬件环境及系统所采用体系结构系统体系结构为C/S结构,具体开发工具为Ecplise ,前台为Java,后台数据库一般为SQL Server2012。四、需求分析通过对学生信息管理了解,确定本系统具备一下功能。多用户账号登录只要通过用户登录验证后,能对学生记录信息进行修改,增加,删除等操作。五、系统设计 1系统结构图a.功能模块图2数据库设计学生包含信息: N MLogin表USE StudentGOSET ANSI_NULLS ONGOSET QUOTED_IDENTIFIE
3、R 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_PAGE_LOCKS = ON) ON PRIMARY) ON PRIMARYGOStudentIf
4、or表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, CONSTRAINT PK_StudentInfor PRIMARY KEY CLUSTERED ( c
5、ode 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, CONSTRAINT PK_Course PRIMARY KEY CLUSTERED ( courseID
6、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, courseGrade float NULL, CONSTRAINT PK_Student_Co
7、urse 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编写前端用户界面主要界面代码如下:public class windows implements ActionListener p
8、rivate JFrame frame; private JLabel label; private JTextField textField; private JList list; private JScrollPane jscrollPane; private DefaultListModel listModel; private JRadioButton mjRadioButton, fjRadioButton; private ButtonGroup setButtonGrop; private JButton button; private JButton jbu; private
9、 Container con; private ResultSet resultSet; private String sinfor = * 学号:,* 姓名:,* 性别:,*宿舍:,住址:,电话:; private String binfor = 增加,删除,修改,查找,上一条,下一条; public windows() frame = new JFrame(学生信息管理 ); con = frame.getContentPane(); con.setLayout(null); frame.setLocation(350, 150); frame.setSize(7770/15, 6000/
10、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); if(i != 2) textFieldi = new JTextField(); textFieldi
11、.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 + (2 * 670/15); mjRadioButton.addActionListener(this);
12、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.getPredefinedCursor(Cursor.HAND_CURSOR); fjRadioButton.setVisib
13、le(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(1570/15,370/15); buttoni.setCursor(Cursor.getPredefi
14、nedCursor(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.setSize(1570/15, 800/15); jbu.setLocation(3 * 2000/15, 4
15、300/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); catch (SQLException e) e.printStackTrace(); se.isDi
16、sconnection(); 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(list); jscrollPane.setSize(200, 250); jscrollPane.s
17、etLocation(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 se; str = value.toString().substring(0, 8); str.trim(); s
18、e = 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); textField3.setText(re.getString(room); textField4.setText(re.ge
19、tString(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; if(e.getSource() = button0) code = textField0.getText(
20、); 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 = textField5.getText(); code.trim(); name.trim(); room.tr
21、im(); 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, 增加成功); select se = new select(); resultSet = se.selectTable()
22、; 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 i = 0; i 6; i+) if(i != 2) textFieldi.setText(); else J
23、OptionPane.showMessageDialog(frame, 增加失败,请核对信息); else JOptionPane.showMessageDialog(frame, 填入信息不全,请核对,警告,JOptionPane.WARNING_MESSAGE); if(e.getSource() = mjRadioButton | e.getSource() = fjRadioButton) sex = e.getActionCommand(); if(e.getSource() = button1) String deli = null; deli = JOptionPane.show
24、InputDialog(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 = new DefaultListModel(); try while(resultSet.next() listM
25、odel.addElement(resultSet.getString(code) + + resultSet.getString(name); catch (SQLException e1) e1.printStackTrace(); list.setModel(listModel); se.isDisconnection(); else JOptionPane.showMessageDialog(frame, 删除失败,请核对信息); else JOptionPane.showMessageDialog(frame, 学号不能为空,错误,JOptionPane.ERROR_MESSAGE)
26、; 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 = textField3.getText(); address = textField4.getText(); tel =
27、 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(); resultSet = se.selectTable(); listModel = new DefaultListModel(
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1