alibaba/spring-ai-alibaba · error · IllegalArgumentException
jdbcUrl cannot be null or blank
Error message
jdbcUrl cannot be null or blank
What it means
SimpleJdbcDataSource (the internal DataSource wrapper used by DatabaseStore) validates its constructor arguments and throws this IllegalArgumentException when jdbcUrl is null or blank, because a DataSource without a URL cannot obtain connections.
Source
Thrown at spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/store/stores/DatabaseStore.java:254
*/
private static final class SimpleJdbcDataSource implements DataSource {
private final String jdbcUrl;
private final String username;
private final String password;
/**
* Construct a simple DataSource from JDBC URL and credentials.
*
* @param jdbcUrl JDBC URL
* @param username database username
* @param password database password
*/
private SimpleJdbcDataSource(String jdbcUrl, String username, String password) {
if (jdbcUrl == null || jdbcUrl.isBlank()) {
throw new IllegalArgumentException("jdbcUrl cannot be null or blank");
}
this.jdbcUrl = jdbcUrl;
this.username = username;
this.password = password;
}
/**
* Open a connection using configured credentials.
*
* @return JDBC connection
* @throws SQLException if connection opening fails
*/
@Override
public Connection getConnection() throws SQLException {
return DriverManager.getConnection(jdbcUrl, username, password);
}
/**View on GitHub (pinned to f82da0b50f)
Solutions
- Supply a complete JDBC URL such as jdbc:mysql://host:3306/db or let DatabaseStore build it from dbType/host/port/database
- Verify the code path constructing SimpleJdbcDataSource actually passes the resolved URL, not a placeholder
- Log/validate the resolved URL before constructing the store
Example fix
// before new DatabaseStore(null, user, pass, table); // after String url = "jdbc:postgresql://localhost:5432/aidb"; new DatabaseStore(url, user, pass, table);
Defensive patterns
Strategy: validation
Validate before calling
if (jdbcUrl == null || !jdbcUrl.startsWith("jdbc:")) throw new IllegalArgumentException("A valid jdbc: URL is required"); Type guard
boolean isJdbcUrl(String url) { return url != null && url.startsWith("jdbc:") && url.length() > 10; } Try / catch
try { dataSource = new DatabaseStore(url, user, pass, table); } catch (IllegalArgumentException e) { if (e.getMessage().contains("jdbcUrl")) { log.error("Bad JDBC URL: " + url); } throw e; } Prevention
- Always build URLs via DatabaseStore's buildJdbcUrl helper rather than hand-rolling
- Confirm URL resolution happened before constructing the DataSource
- Log the (sanitized) URL at debug level to spot empty values early
When it happens
Trigger: Constructing SimpleJdbcDataSource (or using the DatabaseStore constructor path that wraps a raw jdbcUrl) with a null/empty URL — e.g. buildJdbcUrl returned null, or the user supplied an explicit empty jdbcUrl.
Common situations: Custom jdbcUrl config value left blank while bypassing host/port validation; refactored code passing an uninitialized URL variable; configuration loader returning empty string for missing keys.
Related errors
- Unable to load checkpoints
- Unable to load latest checkpoint
- Unable to release checkpoint
- Unsupported dbType: {dbType}. Supported values: mysql, postg
- dbType cannot be null or blank
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/4741185277b8f9ed.
Report an issue: GitHub.