keeping the history of table in java

后端 未结 11 1731
误落风尘
误落风尘 2020-12-10 09:54

I need the sample program in Java for keeping the history of table if user inserted, updated and deleted on that table. Can anybody help in this?

Thanks in advance

11条回答
  •  旧时难觅i
    2020-12-10 10:48

    You have two options for this:

    1. Let the database handle this automatically using triggers. I don't know what database you're using but all of them support triggers that you can use for this.
    2. Write code in your program that does something similar when inserting, updating and deleting a user.

    Personally, I prefer the first option. It probably requires less maintenance. There may be multiple places where you update a user, all those places need the code to update the other table. Besides, in the database you have more options for specifying required values and integrity constraints.

提交回复
热议问题