I am creating a GUI that is dependent on information from MySQL table, what i want to be able to do is to display a message every time the table is updated with new data. I am not sure how to do this or even if it is possible. I have codes that retrieve the newest MySQL update but I don’t know how to have a message every time new data comes into a table. Thanks!
Share
Quite simple and straightforward solution will be just to poll the latest autoincrement id from your table, and compare it with what you’ve seen at the previous poll. If it is greater — you have new data. This is called ‘active polling’, it’s simple to implement and will suffice if you do this not too often. So you have to store the last id value somewhere in your GUI. And note that this stored value will reset when you restart your GUI application — be sure to think what to do at the start of the GUI. Probably you will need to track only insertions that occur while GUI is running — then, at the GUI startup you need just to poll and store current id value, and then poll peroidically and react on its changes.