risingwavelabs/risingwave · error
failed to parse jdbc url
Error message
failed to parse jdbc url
What it means
After stripping the `jdbc:` prefix, `parse_jdbc_url` parses the remainder with the `url` crate. If the remaining string is not a valid absolute URL (bad scheme/host syntax, unparseable authority, invalid characters), the parse error is wrapped with this context: 'failed to parse jdbc url'.
Solutions
- Use the canonical form `jdbc:postgresql://host:port/dbname?user=...&password=...`.
- URL-encode special characters (e.g. `@`, `#`, spaces) in user/password via percent-encoding.
- Verify no stray whitespace or quotes were pasted into the `jdbc.url` property.
- Test the URL by stripping `jdbc:` and confirming it parses as a standard postgres URL.
Example fix
// before jdbc.url = 'jdbc:postgresql://my host:5432/db' // after jdbc.url = 'jdbc:postgresql://my-host:5432/db'
Defensive patterns
Strategy: validation
Validate before calling
let stripped = jdbc_url.strip_prefix("jdbc:").unwrap();
assert!(url::Url::parse(stripped).is_ok(), "jdbc url must parse after stripping jdbc: prefix"); Try / catch
match sink_creation_result { Err(e) if e.to_string().contains("failed to parse jdbc url") => { /* fix and resubmit CREATE SINK */ }, ... } Prevention
- Percent-encode special characters in user/password.
- Avoid spaces and stray quotes in the URL property.
- Test the URL with any standard URL parser before applying.
When it happens
Trigger: A URL like `jdbc:postgresql:host:5432/db` or `jdbc:postgresql:///db` without a host, or containing spaces/illegal characters, that fails `Url::parse` after the `jdbc:` prefix is removed.
Common situations: Typos such as missing `//` after the scheme; unencoded special characters (spaces, `#`) in password or database name; hand-edited URLs in sink properties.
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.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- missing db_name in 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/fb6230207cd343c1.
Report an issue: GitHub.
Appendix: source
Thrown at src/stream/src/from_proto/sink.rs:398
host: String,
port: u16,
db_name: String,
username: Option<String>,
password: Option<String>,
}
fn parse_jdbc_url(url: &str) -> anyhow::Result<JdbcUrl> {
if !url.starts_with("jdbc:postgresql") {
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());
}View on GitHub (pinned to 6469eb736d)