⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 passwordsquery.java~13~

📁 学生信息管理系统,包括成绩查询,成绩排序,用ACCESS做数据库连接
💻 JAVA~13~
字号:
package Chapter1;import java.io.*;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;import java.awt.Rectangle;import java.awt.Font;public class  PasswordsQuery extends JFrame implements ActionListener{   public static final int WIDTH=400;   public static final int HEIGHT=400;  JLabel jLabel1 = new JLabel();  JTextField jTextField1 = new JTextField();  JButton jButton1 = new JButton();  JButton jButton2 = new JButton();  JButton jButton3 = new JButton();   public PasswordsQuery()   {     setSize(WIDTH,HEIGHT);     setTitle("查询密码");     Container contentPane=getContentPane();     contentPane.setBackground(Color.green);    try    {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }   }   public void actionPerformed(ActionEvent e)   {     if(e.getActionCommand().equals("查询"))        { //用于获取用户输入的信息           try           { String password="";             String url="jdbc:odbc:MySecondAccess";             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");             Connection con=DriverManager.getConnection(url,"","");             Statement stmt=con.createStatement();             String  SQLOrder="SELECT * FROM StudentsInformation INNER JOIN ManagersInformation ON StudentsInformation.密码 WHERE 帐号='"+jTextField1.getText()+"' ";             ResultSet resultSet=stmt.executeQuery(SQLOrder);            if(resultSet.next())            {                 password=resultSet.getString(3);                 JOptionPane.showMessageDialog(null,"密码是"+password,"提示信息",JOptionPane.INFORMATION_MESSAGE);            }            else              JOptionPane.showMessageDialog(null,"对不起,不存在此帐号!","张呈刚提醒您.......",JOptionPane.WARNING_MESSAGE);             stmt.close();             con.close();           }           catch(Exception ex)           {             System.out.println("Failure in connecting with the database!");             System.out.println(ex.getMessage());           }        }      else if (e.getActionCommand().equals("重置"))      {          jTextField1.setText("");      }      else if  (e.getActionCommand().equals("返回"))      {           this.setVisible(false);           ManagerInterface n1= new ManagerInterface();           StudentInterface n2=new  StudentInterface();           if(Login.jComboBox1.getSelectedIndex()==0)                 {  n1.setVisible(true);  n2.setVisible(false);}           else if(Login.jComboBox1.getSelectedIndex()==1)                 {  n2.setVisible(true);  n1.setVisible(false); }      }   }   public static void main(String[] args)   {       PasswordsQuery n=new PasswordsQuery();       n.setVisible(true);   }  private void jbInit() throws Exception {    jLabel1.setFont(new java.awt.Font("Dialog", 1, 13));    jLabel1.setText("请输入帐号:");    jLabel1.setBounds(new Rectangle(61, 106, 106, 26));    this.setLocale(java.util.Locale.getDefault());    this.getContentPane().setLayout(null);    jTextField1.setText("");    jTextField1.setBounds(new Rectangle(169, 109, 90, 22));    jButton1.setBounds(new Rectangle(42, 237, 70, 30));    jButton1.setFont(new java.awt.Font("Dialog", 1, 13));    jButton1.setText("查询");    jButton2.setBounds(new Rectangle(162, 236, 70, 30));    jButton2.setFont(new java.awt.Font("Dialog", 1, 13));    jButton2.setText("重置");    jButton3.setBounds(new Rectangle(278, 236, 70, 30));    jButton3.setFont(new java.awt.Font("Dialog", 1, 13));    jButton3.setText("返回");    this.getContentPane().add(jButton1, null);    this.getContentPane().add(jButton2, null);    this.getContentPane().add(jButton3, null);    this.getContentPane().add(jLabel1, null);    this.getContentPane().add(jTextField1, null);    jButton1.addActionListener(this);    jButton2.addActionListener(this);    jButton3.addActionListener(this);  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -