Uncaught Exceptions despite try-catch
in
Contributed Library Questions
•
1 year ago
Hi guys! This is my first time posting in the forums! I really love Processing, but I'm still getting the hang of it... I'm not the most experienced programmer, but I've been around...
So, on to the problem:
I've written a program to connect to a MySQL database on localhost. I used a try-catch statement in case there was an error. I deliberately made an error to test the try-catch and it didn't work. I still can't figue out why and I thought I'd ask the people who know better!
Here's the code:
- import de.bezier.data.sql.*;
import processing.net.*;
Client refrigerador;
MySQL db;
// PROC vars
final int NOTIFICATION_DELAY = 250;
boolean notification;
int notification_start_time;
int millis_counter = 0;
final int REQUEST_DELAY = 3000;
// Ethernet vars
String ipAddress = "192.168.0.150";
int port = 80;
byte[] temperature_buffer = new byte[2];
final int TEMPERATURE_MASK = 65535;
int temperature;
// MySQL vars
String user = "kurt";
String pass = "kurt_";
String database = "test";
void setup() {
size(200, 200);
background(0); // black
notification = false;
try{
db = new MySQL(this, "localhost", database, user, pass);
}
catch (Exception e){
println("Connection error");
}
if (db.connect()){
println("Connection to DB successful");
}
else{
println("Connection to DB error!");
}
try {
refrigerador = new Client(this, ipAddress, port);
println("\nConnected to: " + refrigerador.ip());
}
catch(Exception e) {
notification = true;
println("Error in connection, PIC did not reply");
}
}
void draw() {}
The same error happens with the connection with the Client: I used a try-catch statement, but it's not caught. Seems like the libraries are managing the Exceptions themselves.
Any ideas?
Thnx!
1