Is there a way for a database to notify it’s JDBC clients of a change?
posted 13 years ago
Is there a way for a database to notify it’s JDBC clients of a change? I have a database with multiple application clients (multiple web servers, desktop applications, etc) each connecting to a single database through JDBC. Each of these clients cache the information as they retrieve it to aid in performance. What is the best way to ensure that the client's cache is synchronized with the database? Currently, what I’m doing is this: whenever one application modifies the database, it’s sends a message to all other clients (through RMI) telling them that a change has been made. However, I don’t like this solution as the number of clients is dynamic, and maintaining a list of known, connected clients can be problematic. What I’d like to see is some sort of observer pattern whereby a JDBC client registers itself with the database, and then the triggers on a table notify all registered users that a change has taken place. However, this solution requires the database to “push” information down the JDBC connection, which is primarily a “pull” (query) architecture. So, what to people suggest for synchronization between clients where clients cache information? Plus, is there a way for a database to push information down a JDBC connection? Eagerly awaiting your suggestions and ideas! JDG