File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Timestamp not updating in mysql

 
Jean Bodemer
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm doing updates to records thru Java and JDBC but the timestamp field doesn't update.

An example:
Address has only two fields
Line1 - varchar(40)
UpdateTime - timestamp

ResultSet rs = this.doQuery("SELECT * FROM address WHERE address.key = 1", true);
rs.updateString("Line1", "street addr");
rs.updateRow();
The above does not update the UpdateTime timestamp.

If however I do a query
"Update address set line1 = 'street addr' where address.key = 1"
Then the timestamp is updated.

Any idea how I can get past this problem?
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
may be this mySQL driver problem. refer this
 
Jean Bodemer
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by adeel ansari:
may be this mySQL driver problem. refer this


Hi adeel,

The problem you refer to is not really a problem but due to the type of table selected which does not have transaction support.

It would appear as if the ResultSet object is just a staging area that keeps tabs on all the objects retrieved and re-writes them when updating. So if I don't update timestamp it just re-writes the old value.

I don't want this to happen and I don't want to update the timestamp on the client as the time may not be the same as the server. Is there a way to force the timestamp field to be updated or a way to remove it from the rowset?

Jean
 
Jean Bodemer
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I managed to get past this issue by setting the timestamp = null before the updateRow() statement

rs.updateTimeStamp("updaterow", null);
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic