Hello,
For your information, we realised the project by getting someone else to write some PHP that updated a mySQL database. It's not the ideal solution in many ways, but it does give us the option of recording every change that takes place, and to be able to map this in time after the event is potentially very useful.
There is a database output that is read by a Processing applet, which we initially used loadStrings() for. This was fine as long as the internet was fine, but as soon as the connection timed out or did something else unexpected, the applet crashed. We solved this by getting a try/catch script off someone else. This is perhaps the most annoying part of the project - having to rely on other people's more sophisticated code makes it really hard to troubleshoot.
In case it's useful to anyone else, I've quoted the try/catch section here.
Quote:
import java.net.*;//import the library you need
import java.io.*;void testURL(String myURL) {
retVal="";
//try and get the url - if you can't get the local one
//stick it all into lines array
if(check.checked != true) {
try
{
println("getting page...");
URLConnection urlConn = new URL("http://www.yoururl.com/yourdata.php").openConnection(); //put your url here
urlConn.setUseCaches(false);
InputStream in = urlConn.getInputStream();
byte buf[] = new byte[4096];
int nSize = in.read(buf);
while(nSize>=0)
{
retVal=retVal+new String(buf,0,nSize);
nSize = in.read(buf);
}
lines = splitTokens(retVal); // this is splitting what we get into an array
// this is debug
// for(int lop=0;lop<lines.length;lop++){
// println(lop+": "+lines[lop]);
// }
indicator = color(100); // screen to grey
println("Success.");
}
catch(Exception e)
{
retVal="in exception";
// print error message
println("Exception: "+e.getMessage());
println("NO INTERNET, using local file." + nf(h, 2) + ":" +nf(m, 2)+":"+ nf(s, 2) + ", " + d +"/"+mon+"/"+y); // report to console
myURL = "/data/levels.txt"; // so USE LOCAL FILE
lines = loadStrings(myURL);
indicator = color(200,0,0); // screen to red
}
} else { // if checkbox == true
myURL = "/data/levels.txt"; // so USE LOCAL FILE
lines = loadStrings(myURL);
println("NO INTERNET, Checkbox checked. " + nf(h, 2) + ":" +nf(m, 2)+":"+ nf(s, 2) + ", " + d +"/"+mon+"/"+y); // report to console
indicator = color(200,0,0); // screen to red
}
}