aspose file tools*
The moose likes JDBC and the fly likes Finding out which row has been updated Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Finding out which row has been updated" Watch "Finding out which row has been updated" New topic
Author

Finding out which row has been updated

Siobhan Chom
Greenhorn

Joined: Jan 19, 2012
Posts: 4
I am writing an application which needs to keep some metadata about the rows of the underlying MySQL server (it communicates with the MySQL server via the JDBC driver).

Effectively, each client has a unique ID and my Java application needs to store, for each row,the uuid of the last client who modified the row.

So far, when a row is inserted I allocate it a slot in a metadata table referenced by its primary key.

The only way I can think of doing this is doing a select on the table (with the same where condition as the update/delete), but this imply that for a given query I'm effectively doubling the work. Does have any better ideas, or known of a JDBC way to do it?

Thanks
Stephan Mueller
Ranch Hand

Joined: May 05, 2010
Posts: 50
There are JDBC drivers which return the id of an updated row (update/insert/delete, while I'm only sure on the insert).
Otherwise, you could consider a similar approach as discussed in this (http://www.coderanch.com/t/564488/JDBC/java/Miscellaneous-JDBC-Queries) thread.
Create stored procedures that take the parameters for the new/updated row and the UUID of the client requesting the operation, this way, ou have everything in your DB.

1. Make it run - 2. Make it run correctly - 3. Make it pretty OR fast/small - 4. ??? - 5. Profit
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Finding out which row has been updated