public void getEvent(String tableClick) {
Events e = new Events();
try {
pst = conn.prepareStatement("SELECT * FROM Event WHERE eventID='"+tableClick+"' ");
rs = pst.executeQuery();
while(rs.next()){
e.setEventName(rs.getString(2));
System.out.println(rs.getString(2));
e.setEventDate(rs.getDate(3));
e.setEventTime(rs.getString(4));
e.setEventVenue(rs.getString(5));
e.setEventDetail(rs.getString(6));
e.setEventOpportunity(rs.getString(7));
e.setEventMoreDetails(rs.getString(8));
e.setEndTime(rs.getString(9));
rs.close();
pst.close();
}
}
catch(SQLException ex){
ex.printStackTrace();
}
} //end getEvent
虽然System.out.println(rs.getString(2)
从数据库中打印一个值,但我无法在我的 bean 中填充此信息。
我正在使用 mutators 来填充JavaBean
,但是当我尝试在 MVC 框架的 View 类中使用访问器时,它显示null
.
这是我在 VIEW 课上的电话
VIEW 类中的方法
public void changeDisplay() {
Events e = new Events();
evTitle.setText(""+e.getEventName());
evWhen.setText("When: "+ e.getEventDate());
evWhere.setText("Where: "+ e.getEventVenue());
evDescription.setText("Description: "+ e.getEventDetail());
evOpportunity.setText("Opporunity: "+ e.getEventOpportunity());
evMoreDet.setText("More Details: "+ e.getEventMoreDetails());
}