{"record":{"id":"00f0f0510f961337","repo":"alibaba/druid","slug":"not-supported-by-druiddatasource","errorCode":null,"errorMessage":"Not supported by DruidDataSource","messagePattern":"Not supported by DruidDataSource","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/com/alibaba/druid/pool/DruidDataSource.java","lineNumber":1370,"sourceCode":"            FilterChainImpl filterChain = createChain();\n            try {\n                return filterChain.dataSource_connect(this, maxWaitMillis);\n            } finally {\n                recycleFilterChain(filterChain);\n            }\n        } else {\n            return getConnectionDirect(maxWaitMillis);\n        }\n    }\n\n    @Override\n    public PooledConnection getPooledConnection() throws SQLException {\n        return getConnection(maxWait);\n    }\n\n    @Override\n    public PooledConnection getPooledConnection(String user, String password) throws SQLException {\n        throw new UnsupportedOperationException(\"Not supported by DruidDataSource\");\n    }\n\n    public DruidPooledConnection getConnectionDirect(long maxWaitMillis) throws SQLException {\n        int notFullTimeoutRetryCnt = 0;\n        for (; ; ) {\n            // handle notFullTimeoutRetry\n            DruidPooledConnection poolableConnection;\n            try {\n                poolableConnection = getConnectionInternal(maxWaitMillis);\n            } catch (GetConnectionTimeoutException ex) {\n                if (notFullTimeoutRetryCnt < this.notFullTimeoutRetryCount && !isFull()) {\n                    notFullTimeoutRetryCnt++;\n                    if (LOG.isWarnEnabled()) {\n                        LOG.warn(\"get connection timeout retry : \" + notFullTimeoutRetryCnt);\n                    }\n                    continue;\n                }\n                throw ex;","sourceCodeStart":1352,"sourceCodeEnd":1388,"githubUrl":"https://github.com/alibaba/druid/blob/fa8dc9912637a2f729eef9f55356621fec18d40e/core/src/main/java/com/alibaba/druid/pool/DruidDataSource.java#L1352-L1388","documentation":"UnsupportedOperationException thrown by getPooledConnection(String user, String password) because DruidDataSource is a single-credential pool: all connections authenticate with the datasource's configured username/password. Per-call credentials have no meaningful implementation, so the JDBC-bridged method deliberately refuses.","triggerScenarios":"A caller invokes dataSource.getPooledConnection(user, password) (the two-argument javax.sql.PooledConnection / ConnectionPoolDataSource method). The override at line 1367 throws unconditionally.","commonSituations":"Generic JDBC tooling or a connection pool bridge that calls the 2-arg getPooledConnection expecting per-user pooling; code ported from a multi-tenant pool; frameworks that introspect and invoke all DataSource methods.","solutions":["Use getConnection() / getConnection(username, password) paths Druid supports, or create a separate DruidDataSource per credential set.","If you need multi-tenant pooling, maintain a map of datasource instances keyed by tenant.","Avoid javax.sql.ConnectionPoolDataSource-style usage of DruidDataSource; treat it as a javax.sql.DataSource."],"exampleFix":"// before\nPooledConnection pc = druidDataSource.getPooledConnection(\"alice\", \"pw\"); // throws\n// after\nDruidDataSource aliceDs = pools.get(\"alice\"); // pre-built per-user pool\nConnection c = aliceDs.getConnection();","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// DruidDataSource is a single-credential pool; never call the 2-arg pooled connection API\npublic static boolean supportsPerUserPooledConnection(javax.sql.DataSource ds) {\n    return !(ds instanceof com.alibaba.druid.pool.DruidDataSource);\n}","tryCatchPattern":null,"preventionTips":["Use getConnection() with the datasource's configured credentials.","For multi-tenant access, maintain a pool-per-credential map, not 2-arg getPooledConnection.","Treat DruidDataSource strictly as a javax.sql.DataSource, not ConnectionPoolDataSource."],"tags":["api","unsupported","multi-tenant","credentials"],"backgroundTag":null,"analyzedSha":"fa8dc9912637a2f729eef9f55356621fec18d40e","analyzedAt":"2026-08-14T04:55:06.789Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}