{"record":{"id":"4741185277b8f9ed","repo":"alibaba/spring-ai-alibaba","slug":"jdbcurl-cannot-be-null-or-blank","errorCode":null,"errorMessage":"jdbcUrl cannot be null or blank","messagePattern":"jdbcUrl cannot be null or blank","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/store/stores/DatabaseStore.java","lineNumber":254,"sourceCode":"     */\n    private static final class SimpleJdbcDataSource implements DataSource {\n\n        private final String jdbcUrl;\n\n        private final String username;\n\n        private final String password;\n\n        /**\n         * Construct a simple DataSource from JDBC URL and credentials.\n         *\n         * @param jdbcUrl JDBC URL\n         * @param username database username\n         * @param password database password\n         */\n        private SimpleJdbcDataSource(String jdbcUrl, String username, String password) {\n            if (jdbcUrl == null || jdbcUrl.isBlank()) {\n                throw new IllegalArgumentException(\"jdbcUrl cannot be null or blank\");\n            }\n            this.jdbcUrl = jdbcUrl;\n            this.username = username;\n            this.password = password;\n        }\n\n        /**\n         * Open a connection using configured credentials.\n         *\n         * @return JDBC connection\n         * @throws SQLException if connection opening fails\n         */\n        @Override\n        public Connection getConnection() throws SQLException {\n            return DriverManager.getConnection(jdbcUrl, username, password);\n        }\n\n        /**","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/store/stores/DatabaseStore.java#L236-L272","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nnew DatabaseStore(null, user, pass, table);\n// after\nString url = \"jdbc:postgresql://localhost:5432/aidb\";\nnew DatabaseStore(url, user, pass, table);","handlingStrategy":"validation","validationCode":"if (jdbcUrl == null || !jdbcUrl.startsWith(\"jdbc:\")) throw new IllegalArgumentException(\"A valid jdbc: URL is required\");","typeGuard":"boolean isJdbcUrl(String url) { return url != null && url.startsWith(\"jdbc:\") && url.length() > 10; }","tryCatchPattern":"try { dataSource = new DatabaseStore(url, user, pass, table); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"jdbcUrl\")) { log.error(\"Bad JDBC URL: \" + url); } throw e; }","preventionTips":["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"],"tags":["database","jdbc","validation"],"backgroundTag":"invalid-constructor-argument","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}