Hi;
I have a java bean with a Timestamp property :
import java.sql.Timestamp;
public Class toto {
private Timestamp createDate;
}
And getter/setter :
public Timestamp getCreateDate() {
return createDate; }
public void setCreateDate(Timestamp cdate) {
this.createDate= cdate; }
Q: how insert this Timestamp property when I insert into database (Mysql), a Toto object ? Like this :
public int insert(Toto t) {
...
stmt = conn.prepareStatement(
"INSERT INTO TOTO (TOTOID, CREATEDATETIME) VALUES (?, ?, )");
stmt.clearParameters();
stmt.setString(1, t.getTotoId());
stmt.setTimestamp(2,new Timesstamp(t.getCreateDate.getTime()));
stmt.executeUpdate();
Regards;
I have a java bean with a Timestamp property :
import java.sql.Timestamp;
public Class toto {
private Timestamp createDate;
}
And getter/setter :
public Timestamp getCreateDate() {
return createDate; }
public void setCreateDate(Timestamp cdate) {
this.createDate= cdate; }
Q: how insert this Timestamp property when I insert into database (Mysql), a Toto object ? Like this :
public int insert(Toto t) {
...
stmt = conn.prepareStatement(
"INSERT INTO TOTO (TOTOID, CREATEDATETIME) VALUES (?, ?, )");
stmt.clearParameters();
stmt.setString(1, t.getTotoId());
stmt.setTimestamp(2,new Timesstamp(t.getCreateDate.getTime()));
stmt.executeUpdate();
Regards;