{"record":{"id":"cf46580edeeac080","repo":"alibaba/druid","slug":"url-not-set","errorCode":null,"errorMessage":"url not set","messagePattern":"url not set","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"critical","filePath":"core/src/main/java/com/alibaba/druid/pool/DruidDataSource.java","lineNumber":1137,"sourceCode":"            }\n\n            if (MockDriver.class.getName().equals(driverClass)) {\n                driver = MockDriver.instance;\n            } else if (\"com.alibaba.druid.support.clickhouse.BalancedClickhouseDriver\".equals(driverClass)) {\n                Properties info = new Properties();\n                info.put(\"user\", username);\n                info.put(\"password\", password);\n                info.putAll(connectProperties);\n                driver = new BalancedClickhouseDriver(jdbcUrl, info);\n            } else if (\"com.alibaba.druid.support.clickhouse.BalancedClickhouseDriverNative\".equals(driverClass)) {\n                Properties info = new Properties();\n                info.put(\"user\", username);\n                info.put(\"password\", password);\n                info.putAll(connectProperties);\n                driver = new BalancedClickhouseDriverNative(jdbcUrl, info);\n            } else {\n                if (jdbcUrl == null && (driverClass == null || driverClass.length() == 0)) {\n                    throw new SQLException(\"url not set\");\n                }\n                driver = JdbcUtils.createDriver(driverClassLoader, driverClass);\n            }\n        } else {\n            if (this.driverClass == null) {\n                this.driverClass = driver.getClass().getName();\n            }\n        }\n    }\n\n    protected void initCheck() throws SQLException {\n        DbType dbType = DbType.of(this.dbTypeName);\n\n        if (dbType == DbType.oracle) {\n            isOracle = true;\n\n            // Some Oracle-compatible databases may use non-Oracle JDBC drivers (e.g. YashanDB),\n            // whose version numbers are not aligned with Oracle's. In that case, skip the Oracle","sourceCodeStart":1119,"sourceCodeEnd":1155,"githubUrl":"https://github.com/alibaba/druid/blob/fa8dc9912637a2f729eef9f55356621fec18d40e/core/src/main/java/com/alibaba/druid/pool/DruidDataSource.java#L1119-L1155","documentation":"SQLException('url not set') thrown in resolveDriver() when no Driver instance is provided AND both jdbcUrl is null and driverClass is null/empty. Without either a URL or a driver class, Druid has nothing to load a JDBC driver from, so it refuses to proceed with driver resolution.","triggerScenarios":"resolveDriver() reaches the else branch (line 1135) with jdbcUrl == null and (driverClass == null or empty). The check at 1136 throws before JdbcUtils.createDriver is called.","commonSituations":"Constructing DruidDataSource and calling init() without setUrl/setJdbcUrl and without setDriverClassName; property binding that failed to map url onto the datasource (e.g. wrong property name in Spring config); a config source returning null.","solutions":["Call dataSource.setUrl(\"jdbc:...\") (or setJdbcUrl) before init().","Alternatively set dataSource.setDriverClassName(\"...\") so a driver can be resolved even without a url (though a url is still needed to connect).","Verify your framework's property binding actually populated the url field (log dataSource.getUrl()/getJdbcUrl() before init).","For Spring Boot, confirm spring.datasource.url maps to the Druid datasource (use the druid-spring-boot-starter)."],"exampleFix":"// before\nDruidDataSource ds = new DruidDataSource();\nds.init(); // url not set\n// after\nDruidDataSource ds = new DruidDataSource();\nds.setUrl(\"jdbc:mysql://localhost:3306/mydb\");\nds.setUsername(\"user\");\nds.setPassword(\"pass\");\nds.init();","handlingStrategy":"validation","validationCode":"if ((dataSource.getJdbcUrl() == null || dataSource.getJdbcUrl().isEmpty())\n    && (dataSource.getDriverClassName() == null || dataSource.getDriverClassName().isEmpty())) {\n    throw new IllegalStateException(\"set url (or driverClassName) before init()\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set the jdbc url during datasource construction.","Verify framework property binding populated the url field (log it before init).","Use the druid-spring-boot-starter so spring.datasource.url maps correctly."],"tags":["config","driver","init","missing-config"],"backgroundTag":null,"analyzedSha":"fa8dc9912637a2f729eef9f55356621fec18d40e","analyzedAt":"2026-08-14T04:55:06.789Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}