我有一个Java MVC模型。其中时间戳是已插入DB的DB值之一。我已经在DB中声明了数据类型为Timestamp,现在的问题是如果我尝试检索它正在显示空值并可以不表示为java.sql.Timestamp

声明:

pstmt = con.prepareStatement("SELECT timestamp, FROM nid where id=?");
pstmt.setDouble(1, nidev);
        rs = pstmt.executeQuery();
        if(rs.next())
        {
            timeBean.setHbtimestamp(rs.getTimestamp("timestamp"));

        }


豆类:

private Timestamp hbtimestamp;

public Timestamp getHbtimestamp() {
return hbtimestamp;
}
public void setHbtimestamp(Timestamp hbtimestamp) {
this.hbtimestamp = hbtimestamp;
}


成功插入MyDB值:2015-05-15 13:54:53

输出:值'0000-00-00 00:00:00'不能表示为java.sql.Timestamp

最佳答案

删除,使其看起来像这样

SELECT `timestamp` FROM nid where id=?

07-28 10:18