aspose file tools*
The moose likes JDBC 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
Bookmark "mysql timestamp" Watch "mysql timestamp" New topic
Author

mysql timestamp

jite eghagha
Ranch Hand

Joined: Oct 06, 2006
Posts: 127
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
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3704
    
    5

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


My Blog: Down Home Country Coding with Scott Selikoff
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3704
    
    5

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: 127
thank you, DATETIME works fine.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: mysql timestamp