我有一个Java MVC模型。它有时间戳作为已插入DB的DB值之一。我已将数据类型声明为DB中的时间戳,现在问题是如果我尝试检索它显示为null价值观和不能表示为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"));
}
Bean类:
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
答案 0 :(得分:2)
删除,
,使其看起来像这样
SELECT `timestamp` FROM nid where id=?