I have a java MVC architecture(Simple MVC not used any Framework) which will connect to DB & the query will fetch the time-stamp value which is in the MySQL DB.But I am not getting the expected output it is throwing
Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp For this exception ,I Googled many of them said to add parameters in the DB URL i tried that
"jdbc:mysql://localhost:3306/acc_dev_db?connectTimeout=100000&autoReconnect=true&zeroDateTimeBehavior=convertToNull"
After adding this I am getting o/p as null
Here is my code :
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());
}