我有一个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-14 15:45:57
输出:值'0000-00-00 00:00:00'无法表示为 java.sql.Timestamp