• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Finding out which row has been updated

 
Siobhan Chom
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic