开发者

Monitoring DB: MySQL

开发者 https://www.devze.com 2023-01-05 10:42 出处:网络
I am writing to ask for advice. I 开发者_如何学Chave to monitor certain \"insert\" on a mysql db.

I am writing to ask for advice. I 开发者_如何学Chave to monitor certain "insert" on a mysql db. In what way is more convenient to do this? The application uses Servlets and MySQL. Thank you very much


Depends on the persistence framework you're using.

  • If it's Hibernate, you need to implement an Interceptor and hook on onSave().
  • If it's JPA, you need to use an entity method with the @PrePersist or @PostPersist annotation.
  • If it's plain vanilla JDBC, just add the code to the boilerplated DAO method.

This is unrelated to servlets. The servlet is just an API for intercepting on HTTP requests. Your data access layer should be independent and transparent from that.

0

精彩评论

暂无评论...
验证码 换一张
取 消