3

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!

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

sorry for the late accept, I forgot which login I used for this :| and yes, modifying the code-base is the best way to go! thanks!
0

It depends on the database you are using, as some allow you to run code that would allow you to make a call to a server, through a trigger, but, then you take a performance hit on these modifications, so you would want to use a webservice that doesn't send any information back to, to limit the performance hit.

It also depends on if you are using a server, as then you could use AspectJ to monitor any of the update queries.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.