risingwavelabs/risingwave · error

missing port in jdbc url

Error message

missing port in jdbc url

What it means

`parse_jdbc_url` requires an explicit TCP port and bails with 'missing port in jdbc url' when `Url::port()` returns `None` (i.e. no `:port` in the URL). Unlike JDBC drivers, this connector does not default to 5432.

Solutions

  1. Add the port explicitly: `jdbc:postgresql://host:5432/db`.
  2. Use 5432 unless the postgres server listens on a custom port.
  3. Verify the URL after editing — every part (host, port, dbname) must be present.
  4. Recreate the sink with the corrected `jdbc.url`.

Example fix

// before
jdbc.url = 'jdbc:postgresql://pg.example.com/mydb'
// after
jdbc.url = 'jdbc:postgresql://pg.example.com:5432/mydb'
Defensive patterns

Strategy: validation

Validate before calling

let stripped = jdbc_url.strip_prefix("jdbc:").unwrap();
assert!(url::Url::parse(stripped).ok().map(|u| u.port().is_some()).unwrap_or(false), "jdbc url must contain explicit port");

Prevention

When it happens

Trigger: Creating a JDBC sink with `jdbc:postgresql://host/db` — a host without a `:port` suffix — when the sink executor is built.

Common situations: Users omitting the port assuming the postgres default 5432 is applied, as many JDBC clients do; URLs copied from docs that show portless forms.

Understand the failure class

Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.

Related errors


AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11). Data as JSON: /api/errors/9fd04097c4f5350e. Report an issue: GitHub.

Appendix: source

Thrown at src/stream/src/from_proto/sink.rs:407

        bail!(
            "invalid jdbc url, to switch to postgres rust connector, we need to use the url jdbc:postgresql://..."
        )
    }

    // trim the "jdbc:" prefix to make it a valid url
    let url = url.replace("jdbc:", "");

    // parse the url
    let url = Url::parse(&url).map_err(|e| anyhow!(e).context("failed to parse jdbc url"))?;

    let scheme = url.scheme();
    assert_eq!("postgresql", scheme, "jdbc scheme should be postgresql");
    let host = url
        .host_str()
        .ok_or_else(|| anyhow!("missing host in jdbc url"))?;
    let port = url
        .port()
        .ok_or_else(|| anyhow!("missing port in jdbc url"))?;
    let Some(db_name) = url.path().strip_prefix('/') else {
        bail!("missing db_name in jdbc url");
    };
    let mut username = None;
    let mut password = None;
    for (key, value) in url.query_pairs() {
        if key == "user" {
            username = Some(value.to_string());
        }
        if key == "password" {
            password = Some(value.to_string());
        }
    }

    Ok(JdbcUrl {
        host: host.to_owned(),
        port,
        db_name: db_name.to_owned(),

View on GitHub (pinned to 6469eb736d)