```java
String path = uri.getPath();
if (path.equals("/")) {
    return;
}

// remove first slash
if (!path.startsWith("/")) {
    throw new SQLException("Path does not start with a slash: " + path);
}
path = path.substring(1);

List<String> parts = Splitter.on("/").splitToList(path);

// remove last item due to a trailing slash
if (parts.get(parts.size() - 1).isEmpty()) {
    parts = parts.subList(0, parts.size() - 1);
}

if (parts.size() > 2) {
    throw new SQLException("Invalid path segments in URL: " + uri);
}

if (parts.get(0).isEmpty()) {
    throw new SQLException("Catalog name is empty: " + uri);
}
catalog.set(parts.get(0));

if (parts.size() > 1) {
    if (parts.get(1).isEmpty()) {
        throw new SQLException("Schema name is empty: " + uri);
    }
    schema.set(parts.get(1));
}
```