Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect database events with, for example, Java

Is there a way to detect database events, e.g. insert, update and delete, comparable to file access monitors like JNotify (can detect read, create, modify of files and directories)?

Looking for something like database event listeners because I don't want to do polling.

Thanks!

like image 389
Michael Blancaflor Avatar asked Aug 03 '26 13:08

Michael Blancaflor


1 Answers

In general no. AFAIK, no such facility exists in JDBC or in the SQL standards.

It might be possible for certain databases / configurations using database specific functionality. For example, if the database can be configured to run arbitrary Java code in a trigger, you might be able to get it to send an event into a pubsub system that will deliver it to your application code.

But I think it would be better to modify your application code-base to generate the events itself.

like image 168
Stephen C Avatar answered Aug 06 '26 03:08

Stephen C



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!