学生信息管理系统+SQL数据库

合集下载
相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

本人亲自做的,不需要做任何修改即可顺利运行,sql 表也与程序无缝连接,没有未识别部分。

Sql 表如下:CREATE TABLE STU( 学号varchar(14) PRIMARY KEY, 姓名varchar(8) NOT NULL, 密码varchar(8) NOT NULL, 班级varchar(14) NOT NULL , 性别varchar(2), 学校varchar(14) NOT NULL);

CREATE TABLE TCH( 用户名varchar(8) NOT NULL, 密码varchar(8) NOT NULL );

CREATE TABLE成绩表( 学号varchar(14) PRIMARY KEY, 计算机网络varchar(8) NOT NULL, 汽车概论varchar(8) NOT NULL, 初级日语varchar(8) NOT NULL, 接口技术varchar(8) NOT NULL, ava 程序设计varchar(8) NOT NULL, 数据库varchar(8) NOT NULL, 大学物理varchar(8) NOT NULL);

源程序代码: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 = "D:\\Systems\\title.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,100);

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(135,130,100,25);

panel.add(label1);

name.setBounds(265,130,100,25);

panel.add(name); label2.setBounds(135,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 = pwd.getText();

try

{

Class.forName("oracle.jdbc.driver.OracleDriver");

}

catch (ClassNotFoundException ce)

{

JOptionPane.showMessageDialog(ss,ce.getMessage());

} if(stu.isSelected())

{

try

{

Connection con

DriverManager.getConnection("jdbc:oracle:thin:@user29:1521:XE","hr","oracle"); Statement

stmt = con.createStatement();

ResultSet rs = stmt.executeQuery("select * from STU");

while(rs.next())

{

if((rs.getString(" 学

").equals(username))&&(rs.getString(" 密码").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:oracle:thin:@user29:1521:XE","hr","oracle");

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery("select * from TCH");

相关文档
最新文档