私は日付がjdatechooserで指定されたが、EMは継続的にエラーを取得してデータベースからデータを取得する列の日時を持つテーブルがありますここでは、コードは次のようになります。私はデータベースの日付= jdatechooserからデータを取得しようとしています:</p> <blockquote> <p>Cannot make a static reference to the non-static method getDate() from the type JDateChooser</p> </blockquote> <p>:
public void actionPerformed(ActionEvent e) {
Date date = JDateChooser.getDate();
try{
String query = " Select *from Transactions WHERE "+date+"=? ";
PreparedStatement pst = con.prepareStatement(query);
ResultSet rs = pst.executeQuery();
table.setModel(DbUtils.resultSetToTableModel(rs));
}catch (Exception e1){
e1.printStackTrace();
}
}
[静的でないメソッドへの静的参照を作成できません](https://stackoverflow.com/questions/4969171/cannot-make-a-static-reference-to-the-non-static-メソッド) – Oleg
無関係ですが、それは 'PreparedStatement'を使う間違った方法です。クエリは 'Select * from Transactions where date_column =? 'でなければならず、' pst.setDate(date) 'を使って選択した値を渡します。 –