I am trying to read a record from a Mysql database. One column is a date, but my object's java.sql.Date object isn't being populated. It still has null, even though all rows in the table have values for the date column. Here is my Java object.
Here is the Java command I'm using to read from the database.
Here is the description of my table.
Code:
public class Bulletin {
private int id;
private java.sql.Date day;
private String subject;
private String name;
private String note;
private boolean approved;
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public java.sql.Date getDay() {
return this.day;
}
public void setDate(java.sql.Date day) {
this.day = day;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getNote() {
return this.note;
}
public void setNote(String note) {
this.note = note;
}
public boolean isApproved() {
return this.approved;
}
public void setApproved(boolean approved) {
this.approved = approved;
}
}
Code:
return (Bulletin) this.getJdbcTemplate().queryForObject(
"select * from bulletins where id = ?",
new Object[] { id },
new BeanPropertyRowMapper<Bulletin>(Bulletin.class));
Code:
+----------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+---------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| day | date | YES | | NULL | |
| name | varchar(30) | YES | | NULL | |
| subject | varchar(50) | YES | | NULL | |
| note | varchar(2500) | YES | | NULL | |
| approved | tinyint(4) | YES | | NULL | |
+----------+---------------+------+-----+---------+----------------+