关于#java#的问题,如何解决?

package login;

import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import dao.LogonDao;
import model.User;
import util.Jdbc;

import javax.swing.JLabel;
import javax.swing.JOptionPane;

import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JButton;
import javax.swing.ImageIcon;
import java.awt.Toolkit;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.awt.event.ActionEvent;
public class Shop extends JFrame {
Jdbc jdbc= new Jdbc();
LogonDao logondao=new LogonDao();
private JPanel contentPane;
private JTextField textField;
private JPasswordField passwordField;
private JPasswordField passwordField_1;

/**
 * Launch the application.
 */
public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                Shop frame = new Shop();
                frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

/**
 * Create the frame.
 */
public Shop() {
    
    setIconImage(Toolkit.getDefaultToolkit().getImage("C:\\Users\\DELL\\Desktop\\\u603B\u56FE.JPG"));
    setTitle("用户注册");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 619, 507);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);
    
    JLabel lblNewLabel = new JLabel("用户名");
    lblNewLabel.setIcon(new ImageIcon("D:\\Java\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u7528\u6237.png"));
    lblNewLabel.setFont(new Font("宋体", Font.PLAIN, 18));
    lblNewLabel.setBounds(119, 132, 92, 21);
    contentPane.add(lblNewLabel);
    
    textField = new JTextField();
    textField.setBounds(226, 129, 235, 27);
    contentPane.add(textField);
    textField.setColumns(100);
    
    JLabel lblNewLabel_1 = new JLabel("用户注册");
    lblNewLabel_1.setIcon(new ImageIcon("D:\\Java\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u7F8E\u5986.png"));
    lblNewLabel_1.setFont(new Font("楷体", Font.BOLD, 30));
    lblNewLabel_1.setBounds(226, -24, 276, 190);
    contentPane.add(lblNewLabel_1);
    
    JLabel lblNewLabel_2 = new JLabel("密  码");
    lblNewLabel_2.setIcon(new ImageIcon("D:\\Java\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5BC6\u7801.png"));
    lblNewLabel_2.setFont(new Font("宋体", Font.PLAIN, 18));
    lblNewLabel_2.setBounds(119, 198, 92, 21);
    contentPane.add(lblNewLabel_2);
    
    passwordField = new JPasswordField();
    passwordField.setBounds(226, 195, 235, 27);
    contentPane.add(passwordField);
    
    JLabel lblNewLabel_2_1 = new JLabel("确认密码");
    lblNewLabel_2_1.setIcon(new ImageIcon("D:\\Java\\\u65B0\u5EFA\u6587\u4EF6\u5939\\\u5BC6\u7801.png"));
    lblNewLabel_2_1.setFont(new Font("宋体", Font.PLAIN, 18));
    lblNewLabel_2_1.setBounds(119, 275, 113, 21);
    contentPane.add(lblNewLabel_2_1); 
    
    passwordField_1 = new JPasswordField();
    passwordField_1.setBounds(226, 272, 235, 27);
    contentPane.add(passwordField_1);
    
    JButton btnNewButton = new JButton("注册");
    btnNewButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            regesterActionPerformed();
        }

    
    });
    btnNewButton.setIcon(new ImageIcon(Shop.class.getResource("/com/sun/javafx/scene/web/skin/Redo_16x16_JFX.png")));
    btnNewButton.setBounds(130, 351, 108, 36);
    contentPane.add(btnNewButton);
    
    JButton btnNewButton_2 = new JButton("重置");
    btnNewButton_2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            resetActionPerformed(e);
        }

    
    });
    btnNewButton_2.setIcon(new ImageIcon(Shop.class.getResource("/com/sun/javafx/scene/web/skin/Undo_16x16_JFX.png")));
    btnNewButton_2.setBounds(353, 351, 108, 36);
    contentPane.add(btnNewButton_2);
    
    JButton btnNewButton_1 = new JButton("返回上一页");
    btnNewButton_1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            new Ulogin().setVisible(true);
            dispose(); 
        }
    });
    btnNewButton_1.setBounds(474, 422, 123, 29);
    contentPane.add(btnNewButton_1);
}
private void resetActionPerformed(ActionEvent e) {
    // TODO Auto-generated method stub
    textField.setText("");
    passwordField_1.setText("");
    passwordField.setText("");
}

private void regesterActionPerformed() {
    // TODO Auto-generated method stub
    String userName= this.textField.getText();
    String passWord= new String (this.passwordField.getPassword());
    String passWord_1= new String (this.passwordField_1.getPassword());
    if(userName.isEmpty()) {
        JOptionPane.showMessageDialog(null, "用户名不能为空");
          return;
        
    }if(passWord.isEmpty()) {
        JOptionPane.showMessageDialog(null, "密码不能为空");
          return;
        
    }
    if(passWord_1.isEmpty()) {
        JOptionPane.showMessageDialog(null, "确认密码不能为空");
          return;
    }
          if(passWord.equals(passWord_1)) {
              Connection con=null;
              con= jdbc.getConnection();
              User user=new User(userName,passWord);
        int addNum = 0;
        try {
            addNum = LogonDao.addUser(con,user);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            JOptionPane.showMessageDialog(null, "失败");
        } 
        if(addNum==1) {
            JOptionPane.showMessageDialog(null, "注册成功");
            new Ulogin().setVisible(true);
            dispose();
            return;
        }else {
            JOptionPane.showMessageDialog(null, "注册失败");
        
        }
          }else {
              JOptionPane.showMessageDialog(null, "两次密码不一致");
          }
    
}

}

这个代码的报错是这样的

img

你给出这点报错说实话完全没用,一般报错原因首先找的是cause By开头的那一行或者报错开头,那一行就是给出了你详细的报错原因,其次往下找到你对应的类的指定行数,那个给出了你报错的准确地方,然后仔细检查为什么报错即可

img

最上面的报错异常