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

📄 frame5.java~5~

📁 基于Java的物流管理系统的开发与应用
💻 JAVA~5~
字号:
package untitled5;import java.applet.*;import java.sql.*;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.jbcl.layout.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class Frame5 extends JFrame {  JPanel contentPane;  XYLayout xYLayout1 = new XYLayout();  JPasswordField password = new JPasswordField();  JLabel jLabel1 = new JLabel();  JLabel jLabel2 = new JLabel();  JTextField jTextField1 = new JTextField();  JLabel jLabel3 = new JLabel();  //Construct the frame  public Frame5() {    enableEvents(AWTEvent.WINDOW_EVENT_MASK);    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  //Component initialization  private void jbInit() throws Exception  {    contentPane = (JPanel) this.getContentPane();    password.addActionListener(new Frame5_password_actionAdapter(this));    contentPane.setLayout(xYLayout1);    this.setSize(new Dimension(500, 400));    this.setTitle("库存管理系统");    jLabel1.setFont(new java.awt.Font("SansSerif", 0, 25));    jLabel1.setForeground(Color.red);    jLabel1.setText("欢迎进入库存管理系统");    jLabel2.setFont(new java.awt.Font("SansSerif", 0, 20));    jLabel2.setText("姓名");    jTextField1.setText("");    jLabel3.setFont(new java.awt.Font("SansSerif", 0, 20));    jLabel3.setText("密码");    contentPane.add(jLabel1,           new XYConstraints(133, 2, 253, 34));    contentPane.add(jLabel2,   new XYConstraints(92, 142, -1, -1));    contentPane.add(jTextField1,     new XYConstraints(130, 145, 91, 26));    contentPane.add(jLabel3,   new XYConstraints(222, 144, -1, -1));    contentPane.add(password,    new XYConstraints(263, 144, 105, 28));  }  //Overridden so we can exit when window is closed  protected void processWindowEvent(WindowEvent e) {    super.processWindowEvent(e);    if (e.getID() == WindowEvent.WINDOW_CLOSING) {      System.exit(0);    }  }  void password_actionPerformed(ActionEvent e) {      validID();    this.setVisible(false);  }  void validID() {    try {      String str1, str2;      str1 = jTextField1.getText();      str2 = password.getText();      //装载jdbc驱动程序。      //通过下面的程序我们完成对oracle数据库的动态连接。      String driverName = "oracle.jdbc.OracleDriver";      Driver driver = (Driver) Class.forName(driverName).newInstance();      //连接数据库      //在下面的程序中我们连接的数据库是名为“tongfang“的数据库      //登录名是”sa“密码是“tongfang”      Connection con = DriverManager.getConnection(          "jdbc:oracle:thin:@thsspc0791:1521:tongfang", "sa", "tongfang");      //执行动态的sql语句      PreparedStatement pstmt = con.prepareStatement(          //依据读者的名字查询读者的信息的sql语句          " select name ,id,password from work-info where name=?");      //将读者的名字添加到具体的sql语句中      pstmt.setString(1, str1);      //使用ResultSet中的方法executeQuery()来完成sql语句的执行      ResultSet res = pstmt.executeQuery();      //使用getString()来获取sql查询的结果      //String sa=res.getString(1);      if ((!res.next()) || res.getString("password") == null) {        JOptionPane.showMessageDialog(this, "查无此人", "错误",                                      JOptionPane.ERROR_MESSAGE);      }else {        if ( !res.getString("password").equals(str2)) {          JOptionPane.showMessageDialog(this, "密码错误", "错误",                                      JOptionPane.ERROR_MESSAGE);        }else {          System.out.println("zhengque");          do{            System.out.println(res.getString(1)+":" + res.getString(2) +                               ":" +res.getString(3));          }while (res.next());         loader();        }      }      pstmt.close();      con.close();    }catch (InstantiationException e) {      System.out.println(e.getMessage());    }catch (IllegalAccessException e) {      System.out.println(e.getMessage());    }catch (ClassNotFoundException e) {      System.out.println(e.getMessage());    }catch (SQLException edd) {      edd.printStackTrace() ;      System.out.println(edd.getMessage());    }  }  void loader() {   try {     Frame1   Frame= new Frame1();        Frame.show();   }   catch (Exception ew) {         System.out.println(ew.getMessage());   } }}class Frame5_password_actionAdapter implements java.awt.event.ActionListener {  Frame5 adaptee;  Frame5_password_actionAdapter(Frame5 adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.password_actionPerformed(e);  }}

⌨️ 快捷键说明

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