Unreported exception java.sql.SQLException; must be caught or declared to be thrown? [duplicate]

You either need to catch the exception in your method:

public void setupInfo()
{
    try
    {
        // call methods that might throw SQLException
    }
    catch (SQLException e)
    {
        // do something appropriate with the exception, *at least*:
        e.printStackTrace();
    }
}

Or declare the method to throw SQLException:

private void setupInfo() throws SQLException
{
    // call methods that might throw SQLException
}

Leave a Comment