code: public SQLException exceptionWithQuery(String sql, SQLException sqlException,
        boolean explicitClosed) {
      if (explicitClosed) {
        return new SQLException(
            "Connection has explicitly been closed/aborted.\nQuery is: " + subQuery(sql),
            sqlException.getSQLState(),
            sqlException.getErrorCode(), sqlException.getCause());
      }
  
      if (options.dumpQueriesOnException || sqlException.getErrorCode() == 1064) {
        return new SQLException(sqlException.getMessage()
            + "\nQuery is: " + subQuery(sql)
            + "\njava thread: " + Thread.currentThread().getName(),
            sqlException.getSQLState(),
            sqlException.getErrorCode(), sqlException.getCause());
      }
      return sqlException;
    }
docs: Return exception with query information's.
  
  @param sql            current sql command
  @param sqlException   current exception
  @param explicitClosed has connection been explicitly closed
  @return exception with query information