[英]Retrieving Timestamp data from DB using Mysql
I have a Java MVC model.Which has timestamp as one of the DB value which is already inserted into DB.I have declared the data type as Timestamp in DB,Now the problem is If i try to retrieve it is showing null values & can not be represented as java.sql.Timestamp 我有一个Java MVC模型。其中时间戳是已插入DB的DB值之一。我已经在DB中声明了数据类型为Timestamp,现在的问题是如果我尝试检索它正在显示空值并可以不表示为java.sql.Timestamp
Statement : 声明:
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 Class: 豆类:
private Timestamp hbtimestamp;
public Timestamp getHbtimestamp() {
return hbtimestamp;
}
public void setHbtimestamp(Timestamp hbtimestamp) {
this.hbtimestamp = hbtimestamp;
}
MyDB value is successfully inserted :2015-05-14 15:45:57 成功插入MyDB值:2015-05-14 15:45:57
output: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp 输出:值'0000-00-00 00:00:00'不能表示为 java.sql.Timestamp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.