我正在尝试使用组合框按月过滤我的表格,但是每当我选择十月时,即使我的数据库中的时间戳是十月,也不会显示任何内容。
这是我的代码:
String monthSelection = cbbMonthSearch.getSelectedItem().toString();
if (monthSelection == "Month") {
System.out.println("month");
} else if (monthSelection == "October") {
try {
con = DriverManager.getConnection("jdbc:mysql://localhost/studentlogin", "root", "");
//String sql = "SELECT * FROM studentregisterlogin WHERE TimeIn BETWEEN '2020-10-01 00:00:00' AND '2020-10-31 00:00:00' AND SSN=" +jftfSearch.getText();
String sql = "SELECT * FROM studentregisterlogin WHERE TimeIn>='2020-10-01 01:00:00' AND TimeIn<='2020-10-31 23:59:59'";
pst = con.prepareStatement(sql);
pst.executeQuery();
jtTableTime.setModel(DbUtils.resultSetToTableModel(rs));
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
} else if (monthSelection == "November") {
System.out.println("november");
}
将 rs = 添加到 pst.executeQuery(); 解决这个问题
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句