JAVA_连接sqlserver_学生成绩管理系统
Java连接SQL Server2014详细步骤

Java连接SQL Server2014详细步骤(win10版)1、安装SQL Server214,详细安装过程网上有,需要SQL Server214的可以到/s/1dF8ZXHf下载,我已分享,里面包含了密钥,如果安装不成功,可能是.net Framework3.5没有开启,云盘里也有开启.net Framework3.5的步骤。
2、安装完后,打开SQL Server214,它会弹出一个登录界面,先默认Windows身份验证即可,点击连接,之后会出现如下界面:3、右击安全性-->新建-->登录自定义密码,把强制密码过期的勾去掉如下图6、回到主界面,右击如下图的选项,选择属性7、出现如下界面,先点击左边的安全性,然后选择右边的SQL Server和windows身份验证模式,单击确定8、更改了如上一些设置后,要重新启动才能生效,回到主界面,右击如下选项,选择重新启动,之后会弹出是否要重新启动的提示框,选择“是”置好的登录名和密码,点击连接。
如下图10、进入主界面之后,右击左边的数据库选项,选择新建数据库,数据库名称自定义,单击确定。
主要是为了待会java连接数据库做测试用11、打开SQL Server2014配置管理器,默认路径为C:\ProgramData\Microsoft\Windows\StartMenu\Programs\Microsoft SQL Server 2014\配置工具打开之后,找到SQL Server网络配置,展开它的下拉菜单,找到MSSQLSERVER的协议,双击右边的MSSQLSERVER的协议,看TCP/IP选项是否已启用,没启用的话,选中TCP/IP选项,右击选择启用,完成之后如下图12、TCP/IP启用之后,双击它,在弹出的对话框中选择IP地址选项,将IP1的IP地址设置为127.0.0.1,其他IP的地址不用改,只需查看已启用选项是否为“是”,若为否,则把它改为是即可,最后要确认IPALL的TCP/IP端口是否为1433,若不是,也要改为1433,之后点击确定,然后退出。
计算机毕业论文_基于JAVA的学生成绩管理系统的设计与实现

基于JA V A的学生成绩管理系统的设计与实现THE DESIGN AND REALIZATION OF THE RESULT OF STUDENT ADMINISTRATION MANAGEMENT SYSTEM ON THE JA V A学生姓名:学号:年级专业:指导老师:学院:提交日期:2009年11月目录摘要 2前言 41 需求分析 41.1 功能需求分析 41.2 性能需求分析 51.3 数据库需求分析――数据流图 51.4数据结构分析――数据流图 62概要结构设计 92.1系统功能结构设计 92.2 数据库概念结构设计 103逻辑结构设计 104详细设计及功能实现 114.1模块设计与实现 115总结 21参考文献 21致谢 21基于Java的学生成绩管理系统的设计与实现作者:周亚平指导老师:陈义明(湖南农业大学科学技术师范学院2004级计算机科学与技术专业教育班,长沙410128)摘要:随着计算机技术的飞速发展和高等教育体制改革的不断深入,传统教育管理方法、手段以及工作效率已不能适应新的发展需要,无法很好地完成教学管理工作。
提高教学管理水平的主要途径是更新管理者的思想,增强对管理活动的科学认识。
基于Java与SQL server 数据库技术建立一个高校成绩管理系统该系统为管理员、学生和教师提供了查询、修改、增加记录、删除等功能,功能比较落齐全,基本上能满足学生和老师的要求。
关键词:Java;需求分析;概要设计;学生成绩管理系统;The Design And Realization Of the educational administration management system Based On JA V AAuthor: Zhou yappingTutor: Chen yiming(School of Information Science technique normal school,Hunan AgriculturalUniversity,Changsha, 410128)Abstract: Fly technically along with the calculator to develop soon and the higher education system reform of continuously thorough, traditional education management the method, means and work efficiencies have already can't adapt the new development demand, can't complete the teaching management work nicely.The main path that raises the educational administration management level is a thought that renews the governor, strengthenning the science understanding to manage the activity.According to the JA V A build up that system of an educational administration of high school management system's pursue studies with the database technique to living to provided the search, modify, save, increase the record and select elective courses etc. with teacher function, the function relatively falls well-found, can satisfy the request between student and teacher basically.Keyword:JA V A; The need analysis; The essentiadesign; Database; Detailed design前言学生成绩管理工作是高校教育工作的一项重要内容。
连接sqlserver2019的方法

连接sqlserver2019的方法连接SQL Server 2019的方法SQL Server 2019是微软开发的一款关系型数据库管理系统,它具有强大的功能和性能。
在本文中,我们将一步一步回答如何连接到SQL Server 2019数据库。
步骤一:安装SQL Server 2019首先,我们需要安装SQL Server 2019数据库软件。
您可以从微软官方网站上下载安装程序,并按照提示进行安装。
安装过程中,您需要选择适用于您的操作系统的版本,并根据需要选择所需的组件。
步骤二:启动SQL Server 2019服务安装完成后,您需要启动SQL Server 2019服务。
这可以通过打开“服务”管理工具,在列表中找到“SQL Server”服务并选择“启动”来完成。
步骤三:使用SQL Server Management Studio连接SQL Server Management Studio(SSMS)是一个用于管理和操作SQL Server数据库的集成环境。
它是一个免费的工具,可以从微软官方网站上下载并安装。
安装完成后,打开SSMS。
在“连接到服务器”对话框中,您需要提供连接所需的信息。
以下是一些常用的选项:1. “服务器类型”:选择“数据库引擎”作为服务器类型。
2. “服务器名称”:输入SQL Server实例的名称或IP地址。
3. “身份验证”:选择适当的身份验证方法。
如果您使用Windows身份验证,则可以选择“Windows身份验证”。
如果您有SQL Server登录名和密码,则可以选择“SQL Server身份验证”。
输入相应的凭据。
4. “连接到数据库”:选择要连接的数据库。
如果您没有特定的数据库需求,可以选择“<默认>”。
完成这些选项后,单击“连接”按钮即可连接到SQL Server 2019数据库。
步骤四:使用编程语言连接除了使用SSMS之外,您还可以使用各种编程语言连接到SQL Server 2019数据库。
学生成绩管理程序

合肥学院计算机科学与技术系课程设计报告2012~2013学年第二学期课程JA V A语言课程设计课程设计名称学生成绩管理程序学生姓名高昌发学号1104013036专业班级11级计本3班指导教师谭明、张艳明2 0 13 年1 月一、设计目的通过课程设计,学生在下述各方面的能力应该得到锻炼:(1)进一步巩固、加深学生所学专业课程《JAVA语言教程》的基本理论知识,理论联系实际,进一步培养学生综合分析问题,解决问题的能力。
(2)全面考核学生所掌握的基本理论知识及其实际业务能力,从而达到提高学生素质的最终目的。
(3)利用所学知识,开发小型应用系统,掌握运用JAVA语言编写调试应用系统程序,训练独立开发应用系统,进行数据处理的综合能力。
(4)对于给定的设计题目,如何进行分析,理清思路,并给出相应的数学模型。
(5)熟练掌握JAVA语言的事件处理、图形界面、数据库操作等方面的知识。
一、课程设计名称及内容课程设计名称:学生成绩管理程序设计内容:设计一个程序来使用数据库存储学生成绩,进行学生成绩管理程序。
二、任务和要求这是一个简单的使用数据库存储学生成绩的学生成绩管理程序。
数据库中的每条记录包括学号、姓名、生日、分数等信息。
要求能够:(1)有较好的图形界面(2)按照学号查找学生及成绩、能显示全部记录。
(3)能增加、删除、修改记录。
三、详细设计过程该程序使用JDBC-ODBC桥与数据库连接,主要定义:主类和操作类。
主类的主要功能是提供等待用户的操作的主界面(菜单)。
操作类中定义与数据库的连接、提供各种操作界面(增、删、改及统计等操作)。
1、设计的是学生成绩管理程序的界面,如下所示:这个登陆界面的登陆号和密码都已经设计好了,只需要点击登陆则可以进入具体的管理程序。
如果登陆号和密码发生改变则会显示错误提示,具体的子程序代码如下:public class chengjiguanli {public static void main(String[] args) {new denglu();}}/** *登录界面*/@SuppressWarnings("serial")class denglu extends JFrame implements ActionListener {JFrame frame = new JFrame("登陆界面");JPanel imagePanel;ImageIcon bg;JButton button1, button2;Label l1, l2, l3;TextField a1, a2;Box b1, b2, b3, b4, b5;denglu() {Toolkit kit = Toolkit.getDefaultToolkit();Image img = kit.getImage("tubiao.jpg");frame.setIconImage(img);button1 = new JButton("登陆");button2 = new JButton("退出");Panel p1 = new Panel();l1 = new Label("学生成绩管理系统", Label.CENTER);l1.setFont(new Font("隶书", Font.BOLD, 40));l1.setBackground(Color.pink);p1.add(l1);l2 = new Label("登录名");l3 = new Label("密码");a1 = new TextField(10);a2 = new TextField(10);a2.setEchoChar('*');b1 = Box.createVerticalBox();b1.add(l2);b1.add(Box.createVerticalStrut(8));b1.add(l3);b2 = Box.createVerticalBox();b2.add(a1);b2.add(Box.createVerticalStrut(8));b2.add(a2);b3 = Box.createHorizontalBox();b3.add(b1);b3.add(Box.createHorizontalStrut(10));b3.add(b2);b4 = Box.createHorizontalBox();b4.add(button1);b4.add(Box.createHorizontalStrut(10));b4.add(button2);b5 = Box.createVerticalBox();b5.add(b3);b5.add(Box.createVerticalStrut(8));b5.add(b4);button1.addActionListener(this);button2.addActionListener(this);a1.setText("shanshan");a2.setText("shanshan");addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) {dispose();}});bg = new ImageIcon("dlu.jpg");JLabel label = new JLabel(bg);label.setBounds(0, 0, bg.getIconWidth(), bg.getIconHeight());imagePanel = (JPanel) frame.getContentPane();imagePanel.setOpaque(false);imagePanel.setLayout(new FlowLayout());imagePanel.add(p1, BorderLayout.NORTH);imagePanel.add(b5, BorderLayout.CENTER);frame.getLayeredPane().setLayout(null);frame.getLayeredPane().add(label, new Integer(Integer.MIN_VALUE));frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setSize(bg.getIconWidth(), bg.getIconHeight());frame.setBounds(200, 150, 510, 340);frame.setResizable(false);//设置窗口大小不可改变frame.setVisible(true);validate();}public void actionPerformed(ActionEvent e) {if (e.getSource() == button2) {System.exit(0);}if (e.getSource() == button1) {if (a1.getText().equals("shanshan") &&a2.getText().equals("shanshan")) {new chuangkou();frame.dispose();} else {JOptionPane.showMessageDialog(this, "账户密码错误,请重新输入!");}}}}2、点击界面的登陆按钮后会出现选择窗口,分别有六个功能:添加、删除、修改、查询、返回、退出。
学生成绩查询系统

学生成绩查询本题编程实现对学生成绩查询,主要实现一个JSP+JavaBean开发模式,要求:编写一个JavaBean 对数据库实现连接、查询、关闭等功能。
使用MS SQL Server 2005本题使用的数据库名称为:Query_Score。
表的名称为:student表结构:字段名称数据类型备注stu_id varchar(15) 学号stu_name varchar(20) 姓名Java_score int 成绩J2EE_score int 成绩Software_score int 成绩表内容:图1(1) 编写对数据库进行操作的JavaBeanpackage com.database;import java.sql.*;public class MyDbBean{private Statement stmt = null;ResultSet rs = null;private Connection conn = null;private String dsn;//构造函数public MyDbBean() { }//根据dsn参数,加载驱动程序,建立连接public void getConn(String dbname, String uid, String pwd) throws Exception{try{dsn = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=" +dbname;Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();conn = DriverManager.getConnection(dsn, uid, pwd);}catch (Exception ex){ System.err.println("aq.executeQuery: " + ex.getMessage()); } }//执行查询类的SQL语句,有返回集public ResultSet executeQuery1(String sql){rs = null;try{ stmt = conn.createStatement(); rs =stmt.executeQuery(sql); }catch(SQLException ex){ System.err.println("aq.executeQuery:"+ex.getMessage()); }return rs;}//关闭对象public void closeStmt(){ try{ stmt.close(); }catch(SQLException ex){ System.err.println("aq.executeQuery: " + ex.getMessage()); } }public void closeConn(){try{ conn.close(); }catch(SQLException ex){ System.err.println("aq.executeQuery: " +ex.getMessage()); } } }(2) 编写按姓名查询成绩的界面图2<body> <center> <fieldset><legend a="center">学生成绩查询系统</legend><form action="queryscore.jsp"method="post" name="queryForm" >姓名:<input type="text" name="xuehao"><input type="submit" value="查询"></form> </fieldset> </center> </body> (3) 接收从图2中输入姓名,单击查询后,得到如下结果:<body><jsp:useBean id="query" scope="session" class="com.database.MyDbBean"/><%! String stu_name,sql; %><%stu_name=request.getParameter("xuehao").trim();if(stu_name==null){ stu_name=null;}byte b[]=stu_name.getBytes("ISO-8859-1");stu_name=new String(b,"UTF-8");//调用getConn()方法与数据库建立连接query.getConn("Query_Score","sa","");sql="select * from student where stu_name='" +stu_name+ "'";ResultSet rs=query.executeQuery1(sql);out.print("<table border align=center>");out.print("<tr>");out.print("<th width=100>"+"学号"+"</th>");out.print("<th width=100>"+"姓名"+"</th>");out.print("<th width=50>"+"Java成绩"+"</th>");out.print("<th width=50>"+"J2EE成绩"+"</th>");out.print("<th width=50>"+"软件成绩"+"</th>");out.print("</tr>");while(rs.next()){ out.print("<tr align=center>");out.print("<td>"+rs.getString(1)+"</td>");out.print("<td>"+rs.getString(2)+"</td>");out.print("<td>"+rs.getInt(3)+"</td>");out.print("<td>"+rs.getInt(4)+"</td>");out.print("<td>"+rs.getInt(5)+"</td>");out.print("</tr>");}rs.close();query.closeStmt();query.closeConn();%></body>学生成绩查询系统使用JSP、servlet以及JavaBean来实现学生成绩查询系统。
AVA连接sqlserver学生成绩管理系统

《学生成绩管理系统》课程设计实验报告题目学生成绩管理系统学院数学与信息工程学院专业计算机科学与技术班级同组成员编写日期一、课程设计目的做这个小的学生成绩管理系统来加深对JAVA所学知识的巩固,以及学习JAVA与数据库的连接和JAVA的GUI图形界面。
二、需求分析此系统实现如下系统功能:(1)使得学生的成绩管理工作更加清晰、条理化、自动化。
(2)通过用户名和密码登录系统,查询学生基本资料,学生所学课程成绩,等功能。
容易地完成学生信息的查询操作。
(3) 设计人机友好界面,功能安排合理,操作使用方便,并且进一步考虑系统在安全性,完整性,并发控制,备份和恢复等方面的功能要求。
三、系统模块设计此系统可分为2个模块,教师管理模块和学生操作模块,期中教师又包括学生信息输入与学生成绩录入等;学生模块则包括学生成绩查询与学生信息录入查询操作等。
1Class Char(10) ————班级Collage Char(10) ————学院2、教师表Field Type Null Key CommentID Varchar(10) ——PRI 用户名Pwd Varchar(10) ————密码3、成绩表Field Type Null Key CommentSid char(10) ——PRI 学号计算机网络char(10) ————课程Linux操作系统char(10) ————课程计算机专业英语char(10) ————课程计算机信息技术char(10) ————课程Java程序设计char(10) ————课程数据库应用实训char(10) ————课程高等数学char(10) ————课程XML char(10) ————课程五、E-R图六、心得体会通过本次课程设计,成功的完成了这个小型简单的系统的设计,在整个设计过程中我对JAVA使用和它强大的作用有了一个更深刻的认识,尽管这个系统很简单,但是它让我综合运用了这个学期所学的JAVA的很多内容,在此基础上,对JAVA的基础知识得到了更好的巩固。
sqlserver 算分数的方法

sqlserver 算分数的方法使用SQL Server计算分数的方法在进行数据处理和分析时,经常需要对数据进行评分和排序。
SQL Server是一款常用的关系型数据库管理系统,它提供了丰富的功能和语法来处理和计算数据。
本文将介绍如何使用SQL Server计算分数的方法。
1. 准备数据我们需要准备一张包含评分所需数据的表。
假设我们有一张学生表,其中包含学生的姓名和成绩。
我们可以创建一个名为"Students"的表,包含"Name"和"Score"两个字段。
可以使用以下SQL语句创建该表:```sqlCREATE TABLE Students (Name VARCHAR(50),Score INT);```然后,我们可以向该表中插入一些示例数据,以便后续计算分数。
可以使用以下SQL语句插入示例数据:```sqlINSERT INTO Students (Name, Score)VALUES ('张三', 80),('李四', 90),('王五', 70),('赵六', 85);```2. 计算分数接下来,我们可以使用SQL Server提供的函数和语法来计算分数。
常见的计算分数的方法包括平均分、总分、百分比等。
2.1 平均分要计算学生的平均分,可以使用AVG函数。
以下SQL语句将计算学生的平均成绩:```sqlSELECT AVG(Score) AS AverageScoreFROM Students;```该语句将返回一个名为"AverageScore"的字段,其中包含学生的平均成绩。
2.2 总分要计算学生的总分,可以使用SUM函数。
以下SQL语句将计算学生的总成绩:```sqlSELECT SUM(Score) AS TotalScoreFROM Students;```该语句将返回一个名为"TotalScore"的字段,其中包含学生的总成绩。
Java通过JDBC连接SQLServer2017数据库

Java 通过JDBC 连接SQLServer2017数据库⼀、需要明⽩的基础知识数据库名驱动jar(x 表⽰版本号)具体驱动类连接字符串(ip 地址,端⼝号,名字)Oracle ojdbc-x.jaroracle.jdbc.oracleDriver jdbc:oracle:thin:@localhost:1521:ORCL MySQL mysql-connetor-java-x.jar com.mysql.jdbc.Driver jdbc:mysql://localhost:3306/数据库实例名SQLSERVER sqljdbc-x.jar com.mircosoft.sqlserver.jdbc.SQLServerDriver jdbc:mircosoft:sqlserver:localhost:1433;databasename=数据库实例名⼆、操作导⼊jar 包下载Microsoft JDBC Driver 4.0 for SQL Server在这⾥下载:/zh-cn/download/details.aspx?id=11774java1.8对于版本为sqljdbc42在D 盘新建⼀个⽂件夹,命名为sqljdbc42,将sqljdbc42.jar 复制⼀个进去。
右击 我的电脑 → 属性 → ⾼级系统设置(⾼级) → 环境变量,双击CLASSPATH 变量(或选中CLASSPATH 后 → 编辑),在最后⾯追加 “;D:\sqljdbc42 \sqljdbc42.jar” (注意最前⾯有个 ; )若不存在CLASSPATH ,就新建CLASSPATH 变量,并且将其值设为“D:\sqljdbc42 \sqljdbc42.jar”如果是使⽤Tomcat 做服务器,那么我们需要将sqljdbc42.jar 类库⽂件拷贝到C:\apache-tomcat-***(版本号)\lib ⽬录下除此之外还需要将sqljdbc42.jar 类库⽂件拷贝到C:\Program Files (X86)\Java\jre8\lib\ext ⽬录下然后在ecilipse ⾥新建java 项⽬,在src ⽬录右键“BuildPath”,如图添加解压在D 盘的sqljabc.jar ⽂件然后新建class 运⾏即可三、测试连接运⾏⽰例代码:1 package Test;23 import java.sql.*;45 public class Test {67public static void main(String[] args) {8 update();910 }111213public static void update() {14 Connection connection=null;15 String driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver";//SQL数据库引擎16 String dbURL="jdbc:sqlserver://localhost:1433;DatabaseName=tjl";//数据源注意若出现加载或者连接数据库失败⼀般是这⾥出现问题17 String Name="sa";18 String Pwd="19990713";19try{20 Class.forName(driverName);21 connection=DriverManager.getConnection(dbURL,Name,Pwd);22 System.out.println("连接数据库成功");23 }catch(Exception e){24 e.printStackTrace();25 System.out.println("连接失败");26 }27 Statement stmt = null;28try {29 stmt = connection.createStatement();30 } catch (SQLException e) {31// TODO Auto-generated catch block32 e.printStackTrace();33 }34//增删改操作35 String sql_1="insert into student values('990403','佩奇','男','12','1','2101')";36int count_1 = 0;37try {38 count_1 = stmt.executeUpdate(sql_1);39 } catch (SQLException e) {40// TODO Auto-generated catch block41 e.printStackTrace();42 }//返回值表⽰增删改⼏条数据43//处理结果44if(count_1>0){45 System.out.println("更新成功!");46 }47//查询操作48 String sql_2="select * from student";4950//关闭51try {52 stmt.close();53 } catch (SQLException e) {54// TODO Auto-generated catch block55 e.printStackTrace();56 }57try {58 connection.close();59 } catch (SQLException e) {60// TODO Auto-generated catch block61 e.printStackTrace();62 }63 }64 }65测试结果。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
《学生成绩管理系统》课程设计实验报告题目学生成绩管理系统学院专业班级同组成员编写日期一、课程设计目的做这个小的学生成绩管理系统来加深对JAVA所学知识的巩固,以及学习JAVA与数据库的连接和JAVA的GUI图形界面。
二、需求分析此系统实现如下系统功能:(1)使得学生的成绩管理工作更加清晰、条理化、自动化。
(2)通过用户名和密码登录系统,查询学生基本资料,学生所学课程成绩,等功能。
容易地完成学生信息的查询操作。
(3) 设计人机友好界面,功能安排合理,操作使用方便,并且进一步考虑系统在安全性,完整性,并发控制,备份和恢复等方面的功能要求。
三、系统模块设计此系统可分为2个模块,教师管理模块和学生操作模块,期中教师又包括学生信息输入与学生成绩录入等;学生模块则包括学生成绩查询与学生信息录入查询操作等。
四、数据库1、学生表:Field Type Null Key CommentID Varchar(10) ——PRI 用户名(学号)Pwd Varchar(10) ————密码Name Char(10) ————Sex Char(10) ————性别Class Char(10) ————班级Collage Char(10) ————学院2、教师表Field Type Null Key CommentID Varchar(10) ——PRI 用户名Pwd Varchar(10) ————密码3、成绩表Field Type Null Key CommentSid char(10) ——PRI 学号计算机网络char(10) ————课程Linux操作系统char(10) ————课程计算机专业英语char(10) ————课程计算机信息技术char(10) ————课程Java程序设计char(10) ————课程数据库应用实训char(10) ————课程高等数学char(10) ————课程XML char(10) ————课程五、E-R图附录:源代码1、用户登录界面import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.sql.*;public class Systems extends JFrame implements ActionListener {static Systems ss;JPanel panel = new JPanel();JLabel label1 = new JLabel("输入:");JTextField name = new JTextField();JLabel label2 = new JLabel("密码:");JPasswordField pwd = new JPasswordField();JButton Enter = new JButton("登录");JButton Exit = new JButton("退出");String url = "E:\\mysql\\TM1.jpg";ButtonGroup bgp = new ButtonGroup();JRadioButton stu = new JRadioButton("学生");JRadioButton tch = new JRadioButton("教师");public Systems(){super("登录系统");this.setResizable(false);JLabel img = new JLabel(new ImageIcon(url));img.setBounds(0,0,500,125);panel.add(img);stu.setBounds(165,210,70,20);tch.setBounds(265,210,70,20);bgp.add(stu);bgp.add(tch);panel.add(stu);panel.add(tch);Enter.setBounds(150,250,80,20);Exit.setBounds(270,250,80,20);Enter.addActionListener(this);Exit.addActionListener(this);panel.add(Enter);panel.add(Exit);panel.setLayout(null);this.add(panel);label1.setBounds(,130,100,25);panel.add(label1);name.setBounds(265,130,100,25);panel.add(name);label2.setBounds(,165,100,25);panel.add(label2);pwd.setBounds(265,165,100,25);panel.add(pwd);this.setBounds(100,100,500,350);this.setVisible(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}public void actionPerformed(ActionEvent e){if(e.getSource()==Enter){String username , password;username = name.getText();password = new String(pwd.getPassword());try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch (ClassNotFoundException ce){JOptionPane.showMessageDialog(ss,ce.getMessage());}if(stu.isSelected()){try{Connection con = DriverManager.getConnection("jdbc:odbc:shujuku","sa","");Statement stmt = con.createStatement();ResultSet rs = stmt.executeQuery("select * from STU");while(rs.next()){if(rs.getString("ID").equals(username))if((rs.getString("Pwd").equals(password))){JOptionPane.showMessageDialog(ss,"登陆成功");Students stu = new Students();}else{JOptionPane.showMessageDialog(ss,"登录失败");}}rs.close();stmt.close();}catch (SQLException se){JOptionPane.showMessageDialog(ss,se.getMessage());}}else if(tch.isSelected()){try{Connection con = DriverManager.getConnection("jdbc:odbc:shujuku","sa","");Statement stmt = con.createStatement();ResultSet rs = stmt.executeQuery("select * from TCH");while(rs.next()){if(rs.getString("ID").equals(username))if((rs.getString("Pwd").equals(password))){JOptionPane.showMessageDialog(ss,"登陆成功");Teachers tch=new Teachers();}else{JOptionPane.showMessageDialog(ss,"登录失败");}}}catch (SQLException se){JOptionPane.showMessageDialog(ss,se.getMessage());}}}else{System.exit(0);}}public static void main(String[] args){Systems sys = new Systems();}}2、学生登录界面:import java.awt.*;import javax.swing.*;import java.awt.event.*;public class Students extends JFrame implements ActionListener {JMenuBar jmb = new JMenuBar();JMenu Message = new JMenu("信息");JMenu Score = new JMenu("成绩");JMenuItem Item1 = new JMenuItem("插入");JMenuItem Item2 = new JMenuItem("查询");JMenuItem Item3 = new JMenuItem("查询");public Students(){super("学生界面");this.setSize(500,400);this.setVisible(true);this.setResizable(false);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.setJMenuBar(jmb);jmb.add(Message);jmb.add(Score);Message.add(Item1);Message.add(Item2);Score.add(Item3);Item1.addActionListener(this);Item2.addActionListener(this);Item3.addActionListener(this);}public void actionPerformed(ActionEvent e){if(e.getSource()==Item1){AddMsg ad = new AddMsg();}else if(e.getSource()==Item2){Serch ser = new Serch();}else{Score so = new Score();}public static void main(String[] args){Students stu = new Students();}}3、教师登录界面:import java.awt.*;import javax.swing.*;import java.awt.event.*;public class Teachers extends JFrame implements ActionListener {JMenuBar bar = new JMenuBar();JMenu menu1 = new JMenu("信息");JMenu menu2 = new JMenu("成绩");JMenuItem item1 = new JMenuItem("录入信息");JMenuItem item2 = new JMenuItem("录入成绩");JPanel jpl = new JPanel();public Teachers(){super("教师界面");this.setSize(500,300);this.setResizable(false);this.setVisible(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.setJMenuBar(bar);this.add(jpl);jpl.setLayout(null);bar.add(menu1);bar.add(menu2);menu1.add(item1);menu2.add(item2);item1.addActionListener(this);item2.addActionListener(this);}public void actionPerformed(ActionEvent e){if(e.getSource()==item1)AddMsg msg = new AddMsg();}else{Addscore as = new Addscore();}}public static void main(String[] args){Teachers tch = new Teachers();}}4、学生用户添加界面:import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.sql.*;public class AddMsg extends JFrame implements ActionListener {static AddMsg s;/*添加学生信息控件*/JPanel jpl = new JPanel();JLabel label1 = new JLabel("添加基本信息",JLabel.CENTER);JLabel label2 = new JLabel("学号:",JLabel.CENTER);JLabel label3 = new JLabel(":",JLabel.CENTER);JLabel label4 = new JLabel("性别:",JLabel.CENTER);JLabel label5 = new JLabel("班级:",JLabel.CENTER);JLabel label6 = new JLabel("学院:",JLabel.CENTER);JTextField num = new JTextField(2);JTextField nam = new JTextField(4);ButtonGroup bgp = new ButtonGroup();JRadioButton man = new JRadioButton("男");JRadioButton women = new JRadioButton("女");JTextField clas = new JTextField();JTextField scl = new JTextField();JButton reset = new JButton("重置");JButton addmsg = new JButton("添加");public AddMsg(){super("添加学生信息");this.setResizable(false);this.setSize(500,400);this.setVisible(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.add(jpl);jpl.setLayout(null);addmsg.addActionListener(this);reset.addActionListener(this);/*插入面板*/label1.setBounds(100,20,300,20);jpl.add(label1);label2.setBounds(100,50,70,20);jpl.add(label2);num.setBounds(190,50,140,20);jpl.add(num);label3.setBounds(100,90,70,20);jpl.add(label3);nam.setBounds(190,90,140,20);jpl.add(nam);label4.setBounds(100,130,70,20);jpl.add(label4);man.setBounds(190,130,60,20);women.setBounds(270,130,60,20);jpl.add(man);jpl.add(women);bgp.add(man);bgp.add(women);label5.setBounds(100,170,70,20);jpl.add(label5);clas.setBounds(190,170,140,20);jpl.add(clas);label6.setBounds(100,210,70,20);jpl.add(label6);scl.setBounds(190,210,140,20);jpl.add(scl);reset.setBounds(120,250,90,20);addmsg.setBounds(240,250,90,20);jpl.add(reset);jpl.add(addmsg);}public void actionPerformed(ActionEvent e){if(e.getSource()==addmsg){String sex;if(man.isSelected()){sex="男";}else{sex="女";}try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch (ClassNotFoundException ce){JOptionPane.showMessageDialog(s,ce.getMessage());}try{Connection con = DriverManager.getConnection("jdbc:odbc:shujuku","sa","");Statement stmt = con.createStatement();String str = "insert into STU(ID , Pwd , Name , Sex , Class , Collage)values('"+num.getText()+"','"+"123','"+nam.getText()+"','"+se x+"','"+clas.getText()+"','"+scl.getText()+"')";// int a = stmt.executeUpdate("insert into STU(ID , Pwd , Name , Sex , Class , Collage)values('"+num.getText()+"','"+"12345678','"+nam.getText()+"', '"+sex+"','"+clas.getText()+"','"+scl.getText()+"')");System.out.println(str);int a = stmt.executeUpdate(str);if(a==1){JOptionPane.showMessageDialog(s,"已成功添加");}else{JOptionPane.showMessageDialog(s,"添加失败");}stmt.close();}catch (SQLException se){JOptionPane.showMessageDialog(s,se.getMessage());}}else{num.setText("");nam.setText("");clas.setText("");scl.setText("");num.requestFocus();}}public static void main(String[] args){AddMsg amg = new AddMsg();}}5、学生成绩添加:import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.sql.*;public class Addscore extends JFrame implements ActionListener{static Addscore ss;JLabel[] label = {new JLabel("学号:") , new JLabel("计算机网络:") , new JLabel("Linux操作系统:") , new JLabel("计算机专业英语:") , new JLabel("计算机信息技术基础:") , new JLabel("Java程序设计:") , new JLabel("数据库应用实训教程:") , new JLabel("高等数学:") , new JLabel("XML:")};JTextField[] txt = {new JTextField() , new JTextField() , new JTextField() , new JTextField() , new JTextField() ,new JTextField() , new JTextField() ,new JTextField() ,new JTextField() };JButton add = new JButton("添加");JButton reset = new JButton("重置");JPanel jpl = new JPanel();JLabel title = new JLabel("添加学生成绩" , JLabel.CENTER);Font f = new Font("黑体" , Font.BOLD , 16 );int s = 100;public Addscore(){super("添加学生信息");this.setResizable(false);this.setSize(500,600);this.setDefaultCloseOperation(EXIT_ON_CLOSE);this.setVisible(true);this.add(jpl);add.addActionListener(this);reset.addActionListener(this);jpl.setLayout(null);title.setBounds(150,40,200,20);title.setFont(f);title.setForeground(Color.red);jpl.setBackground(Color.LIGHT_GRAY);jpl.add(title);for(int i = 0 ; i <label.length ; i++){label[i].setBounds(100,s,140,20);jpl.add(label[i]);txt[i].setBounds(260,s,140,20);jpl.add(txt[i]);s=s+40;}add.setBounds(150,s,80,20);reset.setBounds(250,s,80,20);jpl.add(add);jpl.add(reset);}public void actionPerformed(ActionEvent e){if(e.getSource()==add){try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch (ClassNotFoundException ce){JOptionPane.showMessageDialog(ss,ce.getMessage());}try{Connection con =DriverManager.getConnection("jdbc:odbc:shujuku","sa","");Statement stmt = con.createStatement();int a = stmt.executeUpdate("insert into 计算机系成绩(SID , 计算机网络 , Linux操作系统 , 计算机专业英语 , 计算机信息技术基础 , Java程序设计, 数据库应用实训教程, 高等数学, Xml)values('"+txt[0].getText()+"','"+txt[1].getText()+"','"+txt[2].ge tText()+"','"+txt[3].getText()+"','"+txt[4].getText()+"','"+txt[5].ge tText()+"','"+txt[6].getText()+"','"+txt[7].getText()+"','"+txt[8].ge tText()+"')");if(a==1){JOptionPane.showMessageDialog(ss,"添加成功");}else{JOptionPane.showMessageDialog(ss,"添加失败");}}catch (SQLException se){JOptionPane.showMessageDialog(ss,se.getMessage());}}else{for(int i = 0 ; i<txt.length ; i++){txt[i].setText("");txt[0].requestFocus();}}}public static void main(String[] args){Addscore as = new Addscore();}}6、学生信息查询:import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.sql.*;public class Serch extends JFrame implements ActionListener {/*查询学生信息控件*/static Serch s;JPanel jpl = new JPanel();JLabel SCH = new JLabel("查询学生信息",JLabel.CENTER);JLabel label1 = new JLabel("请输入学号:",JLabel.CENTER);JButton serch = new JButton("查询");JLabel label2 = new JLabel(":",JLabel.CENTER);JLabel label3 = new JLabel("班级:",JLabel.CENTER);JLabel label4 = new JLabel("学校:",JLabel.CENTER);JLabel label5 = new JLabel("性别:",JLabel.CENTER);ButtonGroup bgp = new ButtonGroup();JRadioButton man = new JRadioButton("男");JRadioButton women = new JRadioButton("女");JTextField num = new JTextField();JTextField nam = new JTextField();JTextField clas = new JTextField();JTextField scl = new JTextField();JButton reset = new JButton("重置");public Serch(){this.setSize(500,400);this.setVisible(true);this.setResizable(false);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.add(jpl);jpl.setLayout(null);serch.addActionListener(this);reset.addActionListener(this);/*查询面板*/SCH.setBounds(100,20,300,20);jpl.add(SCH);label1.setBounds(100,60,100,20);jpl.add(label1);num.setBounds(220,60,140,20);jpl.add(num);serch.setBounds(120,100,90,20);reset.setBounds(260,100,90,20);jpl.add(serch);jpl.add(reset);label2.setBounds(100,140,70,20);jpl.add(label2);nam.setBounds(190,140,140,20);jpl.add(nam);label5.setBounds(100,180,70,20);jpl.add(label5);man.setBounds(205,180,60,20);women.setBounds(285,180,60,20);bgp.add(man);bgp.add(women);jpl.add(man);jpl.add(women);label3.setBounds(100,220,70,20);jpl.add(label3);clas.setBounds(190,220,140,20);jpl.add(clas);label4.setBounds(100,260,70,20);jpl.add(label4);scl.setBounds(190,260,140,20);jpl.add(scl);}public void actionPerformed(ActionEvent e){String id = num.getText();if(e.getSource()==serch){try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch (ClassNotFoundException ce){JOptionPane.showMessageDialog(s,ce.getMessage());}try{Connection con = DriverManager.getConnection("jdbc:odbc:shujuku","sa","");Statement stmt = con.createStatement();ResultSet rs = stmt.executeQuery("select * from STU where ID = '" + id + "'");while(rs.next()){nam.setText(rs.getString("Name"));if(rs.getString("Sex").equals("男")){man.setSelected(true);}else{women.setSelected(true);}clas.setText(rs.getString("Class"));scl.setText(rs.getString("Collage"));}}catch (SQLException se){JOptionPane.showMessageDialog(s,se.getMessage());}}}public static void main(String[] args){Serch sch = new Serch();}}7、学生成绩查询import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.awt.font.*;import java.sql.*;public class Score extends JFrame implements ActionListener {static Score s;JLabel title = new JLabel("查询成绩",JLabel.CENTER);Font f = new Font("楷体",Font.BOLD+Font.ITALIC,16);JPanel jpl = new JPanel();JLabel label1 = new JLabel("请输入学号:",JLabel.CENTER);JTextField num = new JTextField();JButton serch = new JButton("查询成绩");JButton reset = new JButton("重置");JLabel label2 = new JLabel("计算机网络:",JLabel.LEFT);JLabel label3 = new JLabel("Linux操作系统:",JLabel.LEFT);JLabel label4 = new JLabel("计算机专业英语:",JLabel.LEFT);JLabel label5 = new JLabel("计算机信息技术基础:",JLabel.LEFT);JLabel label6 = new JLabel("Java程序设计:",JLabel.LEFT);JLabel label7 = new JLabel("数据库:",JLabel.LEFT);JLabel label8 = new JLabel("高等数学:",JLabel.LEFT);JLabel label9 = new JLabel("XML:",JLabel.LEFT);JTextField[] txt ={ new JTextField() , new JTextField() , new JTextField() , new JTextField() , new JTextField() , new JTextField() ,new JTextField() , new JTextField()};static int p = 140;public Score(){super("查询分数");this.setResizable(false);this.setSize(500,550);this.setVisible(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);title.setFont(f);this.add(jpl);jpl.setLayout(null);title.setBounds(100,20,300,20);jpl.add(title);label1.setBounds(100,60,90,20);jpl.add(label1);num.setBounds(210,60,140,20);jpl.add(num);serch.setBounds(130,100,90,20);reset.setBounds(240,100,90,20);jpl.add(serch);jpl.add(reset);serch.addActionListener(this);reset.addActionListener(this);label2.setBounds(100,140,140,20);label3.setBounds(100,180,140,20);label4.setBounds(100,220,140,20);label5.setBounds(100,260,140,20);label6.setBounds(100,300,140,20);label7.setBounds(100,340,140,20);label8.setBounds(100,380,140,20);label9.setBounds(100,420,140,20);jpl.add(label2);jpl.add(label3);jpl.add(label4);jpl.add(label5);jpl.add(label6);jpl.add(label7);jpl.add(label8);jpl.add(label9);for(int i = 0 ;i<txt.length ; i++){txt[i].setBounds(260,p,140,20);jpl.add(txt[i]);p=p+40;}}public void actionPerformed(ActionEvent e){if(e.getSource()==serch){String id = num.getText();try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch (ClassNotFoundException ce){JOptionPane.showMessageDialog(s,ce.getMessage());}try{Connection con = DriverManager.getConnection("jdbc:odbc:shujuku","sa","");Statement stmt = con.createStatement();ResultSet rs = stmt.executeQuery("select 计算机系成绩.* from STU , 计算机系成绩 where STU.ID ='" + id + "' AND STU.ID = 计算机系成绩.SID");while(rs.next()){for(int i = 0 ; i<txt.length ; i++){txt[i].setText(rs.getString(i+2));}}}文档catch (SQLException se){JOptionPane.showMessageDialog(s,se.getMessage());}}else{for(int i = 0;i<txt.length ; i++){txt[i].setText("");}num.setText("");}}public static void main(String[] args){Score s = new Score();}}。