简体   繁体   中英

How to retrieve TIMESTAMP value from MySQL database

I have this in my MODEL:

public Timestamp getDateadded() {
    return dateadded;
}

/**
 * @param dateadded the dateadded to set
 */
public void setDateadded(Timestamp dateadded) {
    this.dateadded = dateadded;
}

Which is used by my Data Access Object to get and set the time from the database:

while(rs.next())
         {
             comment = new Comment();
             comment.setDetails(rs.getString("details"));
             comment.setDateadded(rs.getTimestamp("dateadded"));
             comment.setUrgency(rs.getInt("urgency"));
             commentList.add(comment);
         }

After getting the values, the values are set to an arrayList which is forwarded to a page and output using JSTL.

However, I CANNOT figure out why it does not show ANY result.

DEBUGGING TRIED: I printed a non-null arrayList and got something like this [Models.Project@17735867] and when I print the value of COMMENT (the one that has error) the output of the print is just []

So that means there is an error in the arrayList.

Would any of you know what's wrong with my code?

将调试放在ResultSet ,确保其具有数据或在while循环代码中进入吗?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM