数据插入到数据库中时出现空指针异常,请问是传值异常还是哪个对象没有实例化?
publicvoidactionPerformed(ActionEvente){DBConnectioncon=newDBConnection();Stringno=No...
public void actionPerformed(ActionEvent e) {
DBConnection con=new DBConnection();
String no=No_jf.getText();//报错的地方,67行
String kindname=Kindname_jf.getText();
String kind=Kind_cob.getSelectedItem().toString();
String month=Month_cob.getSelectedItem().toString();
String department=Department_jf.getText();
String sponsor=Sponsor_jf.getText();
String traintcompany=TraintCompany_jf.getText();
String teacher=teacher_jf.getText();
String teacheringmethods=Teachingmethods_cob.getSelectedItem().toString();
String classhours=ClassHours_jf.getText();
String pay=Pay_jf.getText();
String classstartdate=ClassStartDate_jf.getText();
String classoverdate=ClassOverDate_jf.getText();
String place=Place_jf.getText();
String content=Content_jf.getText();
String examkind=ExamKind_jf.getText();
String books=Books_jf.getText();
String remarks=Remarks_jf.getText();
Traint traint=new Traint();
traint.setNo(no);
traint.setKindname(kindname);
traint.setKind(kind);
traint.setMonth(month);
traint.setDepartment(department);
traint.setSponsor(sponsor);
traint.setTraincompany(traintcompany);
traint.setTeacher(teacher);
traint.setTeachmethods(teacheringmethods);
traint.setClasshours(classhours);
traint.setPay(pay);
traint.setStartdate(classstartdate);
traint.setOverdate(classoverdate);
traint.setPlace(place);
traint.setContent(content);
traint.setExamkind(examkind);
traint.setBooks(books);
traint.setRemarks(remarks);
con.insertintoTraint(traint);
}
});
报错:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.mwq.frame.TrainManagement$1.actionPerformed(TrainManagement.java:67)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) 展开
DBConnection con=new DBConnection();
String no=No_jf.getText();//报错的地方,67行
String kindname=Kindname_jf.getText();
String kind=Kind_cob.getSelectedItem().toString();
String month=Month_cob.getSelectedItem().toString();
String department=Department_jf.getText();
String sponsor=Sponsor_jf.getText();
String traintcompany=TraintCompany_jf.getText();
String teacher=teacher_jf.getText();
String teacheringmethods=Teachingmethods_cob.getSelectedItem().toString();
String classhours=ClassHours_jf.getText();
String pay=Pay_jf.getText();
String classstartdate=ClassStartDate_jf.getText();
String classoverdate=ClassOverDate_jf.getText();
String place=Place_jf.getText();
String content=Content_jf.getText();
String examkind=ExamKind_jf.getText();
String books=Books_jf.getText();
String remarks=Remarks_jf.getText();
Traint traint=new Traint();
traint.setNo(no);
traint.setKindname(kindname);
traint.setKind(kind);
traint.setMonth(month);
traint.setDepartment(department);
traint.setSponsor(sponsor);
traint.setTraincompany(traintcompany);
traint.setTeacher(teacher);
traint.setTeachmethods(teacheringmethods);
traint.setClasshours(classhours);
traint.setPay(pay);
traint.setStartdate(classstartdate);
traint.setOverdate(classoverdate);
traint.setPlace(place);
traint.setContent(content);
traint.setExamkind(examkind);
traint.setBooks(books);
traint.setRemarks(remarks);
con.insertintoTraint(traint);
}
});
报错:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.mwq.frame.TrainManagement$1.actionPerformed(TrainManagement.java:67)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询