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'@'92.106.188.139' (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?

Thanks!!

import de.bezier.data.sql.mapper.*;
import de.bezier.data.sql.*;

String dbHost    = "89.216.113.243:3306";
String dbUser    = "thisisnottherightuser";
String dbPass    = "thisisnottherightpassword";
String dbName    = "testname";

MySQL             mainSQL;

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

Answers

  • 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.