给段中间的代码,点击jButton1时,获得用户名框输入的文本并对其在数据库中进行匹配。如果没有输出“用户名不存在”,编译时没问题,运行时界面也都有,只是点击按钮时会抛出Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at LoginEvent.mouseClicked错误。为什么?
private JButton getJButton1()
 {
  if (jButton1 == null)
  {
   jButton1 = new RButton();
   jButton1.setText("登录");
   jButton1.addMouseListener(new LoginEvent());
 
  }
  return jButton1;
 }
 class LoginEvent extends MouseAdapter
 {
    Connection con = null;
    Statement st = null;
    ResultSet rs = null;
  public void mouseClicked(MouseEvent eee)
  {
   try
   {
    Class.forName("com.mysql.jdbc.Driver");
   }
   catch (ClassNotFoundException ee)
   {
    ee.printStackTrace();
    System.out.println("加载驱动错误");
   }
   try
   {
    String url = "jdbc:mysql://localhost:3306/test?user=root&password=123456";
    Connection con = DriverManager.getConnection(url);
   }
   catch (Exception evt)
   {
    evt.printStackTrace();
    System.out.println("链接错误");
   }
   
   try
   {
    String a = jTextField.getText().trim();//用户名
     st = con.createStatement();
    rs = st.executeQuery("select * from useinfo where username = '"+a+"'");
    int rows = rs.getRow();
    if (rows == 0)
    { System.out.println("用户名不存在"); }
      
    rs.close();
    st.close();
    con.close();
   }
   catch (SQLException ev) { }
  }
 }