• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Insert a timestamp into mysql database

 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 58
 
Campbell Ritchie
Sheriff
Pie
Posts: 49472
64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . or a DEFAULT NOW() value in the datetime column.
 
Sid Murrey
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell's suggestions sound very very right. Forget the Timestamp class :-)
 
Scott Selikoff
author
Saloon Keeper
Posts: 4015
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic