我想只提取具有相同DATE_ADD數據,並輸出到table_patients使用JDateChooser從數據庫檢索數據?
下面是代碼
private void btn_GoActionPerformed(java.awt.event.ActionEvent evt) {
java.util.Date chooser= choose.getDate();
java.sql.Date sqlchooser=new java.sql.Date(chooser.getDate());
try{
String sql="select * from Patients_Details where Date_Add='"+sqlchooser+"'";
pst=conn.prepareStatement(sql);
pst.setDate(1,sqlchooser);
rs=pst.executeQuery();
table_patients.setModel(DbUtils.resultSetToTableModel(rs));
}
catch(SQLException sql)
{ sql.printStackTrace(); }
}
,但我得到這個錯誤
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0
at org.sqlite.PrepStmt.batch(PrepStmt.java:192)
at org.sqlite.PrepStmt.setObject(PrepStmt.java:245)
at org.sqlite.PrepStmt.setDate(PrepStmt.java:290)
at employeeJFrame.btn_GoActionPerformed(employeeJFrame.java:981)
at employeeJFrame.access$1300(employeeJFrame.java:18)
at employeeJFrame$13.actionPerformed(employeeJFrame.java:391)
錯誤點,這條線
pst.setDate(1,sqlchooser);
有人可能請h ELP?注意:我是一個java begginer
這是什麼語言? Java的? JavaScript的?請標記爲這樣。此外請澄清錯誤發生在哪一行。 – 2013-04-30 10:04:42