package com.work;
import com.work.sql_demo;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;import javax.swing.event.*;
import javax.xml.transform.Result;import com.work.error;
public class Demo_denglu extends JFrame implements ActionListener {
JLabel jb1 , jb2,jb3,jb4;
JTextField jt1 ; 
JPasswordField ps = null ;
JButton jb = null;
JPanel jp1,jp2,jp3,jp4,jp5,jp;
public Demo_denglu() {
JLabel jb1 = new JLabel("登录名(学工号)");
JLabel jb2 = new JLabel("    密                      码");
// JLabel jb3 = new JLabel( );
jb3 = new JLabel(new ImageIcon("昭文馆。jpg"));
JTextField jt1 = new JTextField(10);
JPasswordField ps = new JPasswordField(10);
JButton jb = new JButton( "登录");

jb.addActionListener(this); //监听器设置


JLabel jb3 = new JLabel("学生档案管理系统");
JPanel jp1 = new JPanel();
JPanel jp2 = new JPanel();
JPanel jp3 = new JPanel();
JPanel jp4 = new JPanel();
JPanel jp5 = new JPanel();
JPanel jp = new JPanel();

jp1.add(jb3);//登录名称
 
jp2.add(jb1);
jp2.add(jt1);//用户名

jp3.add(jb2);//密码
jp3.add(ps);

jp4.add(jb);//登录按钮 jp.setLayout(new GridLayout(5, 1));
jp.add(jp5);
jp.add(jp1);
jp.add(jp2);
jp.add(jp3);
jp.add(jp4);

this.add(jp);

setTitle("学生档案管理系统登录界面");
setSize( 800, 500);
setLocation(500, 250);
setResizable(false);
setIconImage(new ImageIcon("帅.jgp").getImage());
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);



//设置监听器

}

@SuppressWarnings("deprecation")
@Override
public void actionPerformed(ActionEvent e) {
boolean ifr = false;
PreparedStatement ps1 = null;
Connection ct = null;
ResultSet rs = null;
try {
//加载驱动
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
//得到链接
ct=DriverManager.getConnection("jdbc:microsoft:sqlserver://127.0.0.1:1433;databaseName=studb", "sa", "971023");
//创建火箭车
ps1 =ct.prepareStatement("select * from y_ifm");
rs = ps1.executeQuery();
while (rs.next()) {
if (rs.getString(2)==jt1.getText()&&rs.getString(3)==ps.getText()) {
ifr = true;
}
}

} catch (SQLException e1) {
// TODO 自动生成的 catch 块

System.err.println("匹配账号密码错误");
e1.printStackTrace();
} catch (ClassNotFoundException e1) {
// TODO 自动生成的 catch 块
System.out.println("链接数据库错误");
e1.printStackTrace();
}
finally {
try {
rs.close();
ps1.close();
ct.close();
} catch (SQLException e1) {
// TODO 自动生成的 catch 块
System.out.println("关闭数据流错误");
e1.printStackTrace();
}
}
}

 } if (rs.getString(2)==jt1.getText()&&rs.getString(3)==ps.getText())最后显示这行代码出错
故障贴   Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.work.Demo_denglu.actionPerformed(Demo_denglu.java:91)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$400(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
c