gpt4 book ai didi

java - 为什么我的 SQLite 查询返回的系统日期为 1970-01-01?

转载 作者:行者123 更新时间:2023-12-01 06:10:23 26 4
gpt4 key购买 nike

我正在编写一个 Java 桌面应用程序。这段代码曾经在我的模拟数据库中运行良好。现在它返回 1970-01-01 作为系统日期。我正在使用 eclipse。请帮忙。

JButton btnCheckAvailability = new JButton("Check Availability");
btnCheckAvailability.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {
int count=0;
String q="Select * from IssueLog where Book_id= ?";
try{
PreparedStatement p=con.prepareStatement(q);
p.setString(1,bid);
ResultSet rst=p.executeQuery();

while(rst.next()){
count++;

String q2 ="select date('now')";

PreparedStatement pst5 = con.prepareStatement(q2);
ResultSet rs55 = pst5.executeQuery();
//JOptionPane.showMessageDialog(null,rs55.getDate(1));
if((rs55.getDate(1)).before(rst.getDate("Due_Date"))){
String qw="Select Name from Members where Id_no=?";
PreparedStatement pst0=con.prepareStatement(qw);
pst0.setString(1, rst.getString("id_no"));
ResultSet r = pst0.executeQuery();
JOptionPane.showMessageDialog(null,"It is currently with "+r.getString("Name")+"\nCome back after "+rst.getString("Due_Date"));
pst5.close();
pst0.close();
rs55.close();
r.close();
}
else
JOptionPane.showMessageDialog(null, "Available");


}

rst.close();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if(count!=1)
JOptionPane.showMessageDialog(null, "Available");

}

});

最佳答案

我还是不知道这是怎么发生的。但这是有效的。

                        String q2 ="select date('now')";

PreparedStatement pst5 = con.prepareStatement(q2);
ResultSet rs55 = pst5.executeQuery();
//JOptionPane.showMessageDialog(null,rs55.getString(1));

if(rs55.getString(1).compareTo(rst.getString("Due_Date"))>0){

关于java - 为什么我的 SQLite 查询返回的系统日期为 1970-01-01?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36102232/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com