我有一个java MVC架构(Simple MVC没有使用任何框架),它将连接到DB&查询将获取MySQL DB中的时间戳值。但是我没有得到它正在抛出的预期输出
价值' 0000-00-00 00:00:00'不能表示为java.sql.Timestamp 对于这个例外,我用Google搜索了他们中的许多人说要在我试过的数据库网址中添加参数
" JDBC:MySQL的://本地主机:3306 / acc_dev_db的 connectTimeout = 100000&安培; autoReconnect的=真安培; zeroDateTimeBehavior = convertToNull "
添加后我得到o / p为null
这是我的代码:
public HeartBeatBean getHBDetails(Double nidev) throws SQLException
{
HeartBeatBean hbBean = null;
if(nidev > 0)
{
pstmt = con.prepareStatement("SELECT nidevid,hbtimestamp FROM nidhb where nidevid=? ORDER BY nidhbid");
try {
pstmt.setDouble(1, nidev);
rs = pstmt.executeQuery();
if(rs.next())
{
hbBean = new HeartBeatBean();
rs.getTimestamp("hbtimestamp");
System.out.println(rs.getTimestamp("hbtimestamp"));
hbBean.setHbtimestamp(rs.getTimestamp("hbtimestamp"));
}
}
catch (SQLException ex)
{
System.err.println(ex.getMessage());
}