Catch exception with SQL Library

Hi everyone,

I'm using the Bezier SQL library, and have trouble handling exceptions. In the below code, I'm trying to connect to a database using bad credentials, which throws the exception:

java.sql.SQLException: Access denied for user 'thisisnottherightuser'@'' (using password: YES)

However, putting the database connection in a try/catch statement does not catch the exception, and if the catch is written as catch(SQLException e), I get a compile error saying "This exception is never thrown from the try statement body", even though it clearly does throw it.

Does anyone have a hint as to what I'm doing wrong?



String dbHost    = "";
String dbUser    = "thisisnottherightuser";
String dbPass    = "thisisnottherightpassword";
String dbName    = "testname";

MySQL             mainSQL;

void setup() {
  mainSQL    = new MySQL(this, dbHost, dbName, dbUser, dbPass);
  try {
  } catch (Exception e) {
    println("there was a problem"); 


  • java.sql.SQLException

    catch(SQLException e)

    try catch(java.sql.SQLException e)

    it might be including another class called SQLException from a different package.

    (just guessing here, can't test)

Sign In or Register to comment.