Java: Do something on event in SQL Database? -


I am creating an application with distributed parts. Meaning, while a part (author) is probably stopping reading, updating, reading the second part (reader) in a database and working on that information.

Now, I want to trigger an action event

Is there any easy way to do this?

Is this a good idea? :

  // READER while (true) {connect (); // Information reloaded from the DB execution ("Choose from Foo '); Disconnect ();}  

Edit: More Information

This is a restaurant Point of Sale System.

Every time Cashier DB - The application notification in the kitchen gets it is a system you see in McDonald's.

Connect the applications in any way Should not be.

And I believe I expect instant notifications

The idea that you are talking about is called "voting", just as Grafen Told you to add a delay in the loop, the amount of delay should be fixed on the basis of factors such as how quickly you want your reader to detect any changes in the database and how quickly the author has included / updated data

Next Rectification in Your Solution And there may be a change indicator within the database. Your Elgo will look something like this:

  // READER while (true) {connect (); // db change_count = reload the information from executeQuery (Choose "change_count from change_counters where counter = foo"); If (change_count> final_con_gread) {last_change_count = change_count; Reload (); } Disconnect (); }  

The above changes will ensure that you do not reload the data unnecessarily. You can also create a solution to keep a line level change count so that you can only reload the updated rows.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -