risingwavelabs/risingwave · error
missing db_name in jdbc url
Error message
missing db_name in jdbc url
What it means
`parse_jdbc_url` derives the database name from the URL path and bails with 'missing db_name in jdbc url' when the path does not begin with `/` followed by a name (i.e. `url.path().strip_prefix('/')` fails on an empty path).
Solutions
- Append the database name: `jdbc:postgresql://host:5432/dbname`.
- Ensure there is exactly one `/` then the db name after the port (query params come after `?`).
- Do not leave a trailing slash with empty db name.
- Recreate the sink after fixing the URL.
Example fix
// before jdbc.url = 'jdbc:postgresql://host:5432/' // after jdbc.url = 'jdbc:postgresql://host:5432/mydb'
Defensive patterns
Strategy: validation
Validate before calling
let stripped = jdbc_url.strip_prefix("jdbc:").unwrap();
let has_db = url::Url::parse(stripped).ok().map(|u| u.path().len() > 1).unwrap_or(false);
assert!(has_db, "jdbc url must include /dbname"); Prevention
- Never end the URL at the port; always include /dbname.
- Don't rely on client-side default databases — name it explicitly.
- Validate all four parts (host, port, db, scheme) before CREATE SINK.
When it happens
Trigger: A sink URL like `jdbc:postgresql://host:5432` or `jdbc:postgresql://host:5432/` with no database segment after the port.
Common situations: Users omitting the database name because some client tools default to the username; truncated URLs; editing the URL and dropping the trailing `/dbname`.
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
- failed to parse jdbc url
- missing host in jdbc url
- missing port in jdbc url
- database is required for Snowflake JDBC sink
- invalid jdbc url, to switch to postgres rust connector, we…
AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11).
Data as JSON: /api/errors/8f2ebc24e3810e3f.
Report an issue: GitHub.
Appendix: source
Thrown at src/stream/src/from_proto/sink.rs:409
)
}
// 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(),
username,
password,View on GitHub (pinned to 6469eb736d)