java代码出现异常,
空指针package view;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.PreparedStatement;
import
java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JTextField;
import javax.swing.JButton;
import util.*;
public class AddStuView extends JFrame {
private JPanel contentPane;
private JTextField stuidField;
private JTextField stunameField;
private JTextField sexField;
private JTextField snativeField;
private JTextField phoneField;
private JTextField classField;
private JTextField gradeField;
private JTextField majorField;
private JTextField collegeField;
private Connection con = null;
private Statement stmt = null;
// private PreparedStatement pstmt = null;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
AddStuView frame = new AddStuView();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public AddStuView() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 320);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel label = new JLabel("\u6DFB\u52A0\u5B66\u751F\u4FE1\u606F");
label.setFont(new Font("宋体", Font.PLAIN, 18));
label.setBounds(177, 10, 113, 36);
contentPane.add(label);
JLabel label_1 = new JLabel("\u5B66 \u53F7 \uFF1A");
label_1.setBounds(27, 60, 54, 15);
contentPane.add(label_1);
stuidField = new JTextField();
stuidField.setBounds(78, 57, 121, 21);
contentPane.add(stuidField);
stuidField.setColumns(10);
JLabel label_2 = new JLabel("\u59D3 \u540D \uFF1A");
label_2.setBounds(27, 96, 54, 15);
contentPane.add(label_2);
stunameField = new JTextField();
stunameField.setColumns(10);
stunameField.setBounds(78, 93, 121, 21);
contentPane.add(stunameField);
JLabel label_3 = new JLabel("\u6027 \u522B \uFF1A");
label_3.setBounds(27, 134, 54, 15);
contentPane.add(label_3);
sexField = new JTextField();
sexField.setColumns(10);
sexField.setBounds(78, 131, 121, 21);
contentPane.add(sexField);
JLabel label_4 = new JLabel("\u7C4D \u8D2F \uFF1A");
label_4.setBounds(27, 169, 54, 15);
contentPane.add(label_4);
snativeField = new JTextField();