Processing + MySQL how to detect new data entry in the database

Hello everyone! my problem is how to detect a new data entry into my DB in order to plot the values (temperature + humidity), I´ve been searching a lot and all I could do was it in a very primitive way like this (editing the examples of bezier library examples):

void draw() {

while (row != next_row) { msql.query( "SELECT COUNT(*) FROM temp_y_hum" ); msql.next(); row = msql.getInt(1); println( "number of rows: " + row );
}
next_row= next_row + 1; }

I suspect I am facing the problem in a wrong way, my idea is to get the plot from different computers accessing to the localhost. My idea is to run this code just once at the setup to get the dimension of the table. My main 2 probelms is how to detect a new data entry, and then how to access to it, since all the examples I saw get the whole table using dbconnection.next(). Hope somebody can give a hand on this. Thanks for reading.

Answers

  • First, you should take a look at How to format code and text, it will be useful for longer code snippets...

    Secondly, I think you need to poll the database regularly anyway, if you want to draw a chart with time on the x axis.

  • obrigado for replying Philho, and thanks for nice information!

Sign In or Register to comment.