The moose likes JDBC and Relational Databases and the fly likes mysql timestamp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "mysql timestamp" Watch "mysql timestamp" New topic
Author

mysql timestamp

jite eghagha
Ranch Hand

Joined: Oct 06, 2006
Posts: 128
hey,

I have a problem using timestamp.

if 'A' occurs i wish to set the timestamp to the current time, but if 'B' occurs i wish the timestamp to remain 0.

so i set this code up before the sql command:


I created my table as such:



either way, timestamp is always updated, even if i send a 'null' to the sql coomand for the timestamp column.



Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3748
    
  10

Use DATETIME instead, it stores the same data and doesn't have the 'often flaky' default/auto-insert rules.


[OCA 8 Book] [Blog]
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3748
    
  10

jite eghagha wrote:


Also, I'm not a big fan of this code. How about a non-database dependent alternative such as:

jite eghagha wrote:


Granted, you may have a reason to prefer the database time to the application server, but in practice it often doesn't matter.
jite eghagha
Ranch Hand

Joined: Oct 06, 2006
Posts: 128
thank you, DATETIME works fine.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: mysql timestamp
 
It's not a secret anymore!