File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases 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
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Finding out which row has been updated" Watch "Finding out which row has been updated" New topic

Finding out which row has been updated

Siobhan Chom

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?

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 ( 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:
subject: Finding out which row has been updated
It's not a secret anymore!