• Post Reply Bookmark Topic Watch Topic
  • New Topic

Insert a timestamp into mysql database  RSS feed

 
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe java.sql.Timestamp could be helpful?

http://java.sun.com/javase/6/docs/api/java/sql/Timestamp.html
 
Campbell Ritchie
Marshal
Posts: 56209
171
  • 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
Bartender
Posts: 4093
21
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
Boost this thread!