Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

insert a Timestamp property

Status
Not open for further replies.

nora1966

Programmer
Oct 12, 2006
10
FR
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;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top