| 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: 49
|
|
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
|
 |
 |
|
|
subject: Finding out which row has been updated
|
|
|