Question

How can i send a request to my DB, mySql, then check if there are changes so that i can refresh a div if there are changes?

-EDIT-

This is my code. It just auto refreshes the load function every 5s so that it will apply new changes to the table. I dont know how to send a request to my DB to see changes.

<div id="updateThis">
    Loading........
</div>

<script type="text/javascript">
    $(function refresh(){ 
        setInterval(function(){refresh()},5000);
        $('#updateThis').load('${createLink(controller:'table', action:'loadTables')}');

    });
</script>

No correct solution

OTHER TIPS

A lot depends on the size of your system.

'Enterprise' - look at Flexviews and/or LinkedIn's Data Bus. If neither of those work for you, you should probably look for topics/tools related to Data Warehouse ETL with MySQL, since a large portion of the ETL process is determine efficient ways to extract changed data. For instance, you could look at JasperSoft ETL Pro or Talend Open Studio which has a number of tools to build a custom ETL process.

'Basic' - look at either adding timestamps to the tables in question and then querying for records with a timestamp value greater than the last time you checked (downside: no record of deletes) or add triggers to the database that record changes in data.

Also, if this system is large, you may want to look at pushing the changes via websockets or the like since polling every 5 seconds for changes is not going to scale well. There are a number of articles and Grails plugins (Atmosphere and Events Push to name a couple) on the topic.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top