| Author |
Insert a timestamp into mysql database
|
Gopu Akraju
Ranch Hand
Joined: Jan 13, 2008
Posts: 242
|
|
Hi I have a column in my mysql database as "submitted" of type "DATETIME" data type. Basically for every trasaction in a table, I want to add timestamp data in a column "submitted". How do I do this? Do I have to create through java and try using java bean or is it possible to do directly? Regards Gopu
|
 |
Sid Murrey
Ranch Hand
Joined: Jul 07, 2008
Posts: 58
|
|
Maybe java.sql.Timestamp could be helpful? http://java.sun.com/javase/6/docs/api/java/sql/Timestamp.html
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32675
|
|
|
. . . or a DEFAULT NOW() value in the datetime column.
|
 |
Sid Murrey
Ranch Hand
Joined: Jul 07, 2008
Posts: 58
|
|
|
Campbell's suggestions sound very very right. Forget the Timestamp class :-)
|
 |
Scott Selikoff
Saloon Keeper
Joined: Oct 23, 2005
Posts: 3652
|
|
|
Keep in mind NOW() will use the database time, whereas you may want to use the application server time. For example, if they are out of sync, the database could create records that the application server believes are in the future. In general, its better to have your application server administering time since its making all the decisions.
|
My Blog: Down Home Country Coding with Scott Selikoff
|
 |
 |
|
|
subject: Insert a timestamp into mysql database
|
|
|