{"record":{"id":"cb4759e95aaef6e4","repo":"apache/dolphinscheduler","slug":"get-datasource-tables-error","errorCode":"GET_DATASOURCE_TABLES_ERROR","errorMessage":"Status.GET_DATASOURCE_TABLES_ERROR","messagePattern":"Status\\.GET_DATASOURCE_TABLES_ERROR","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java","lineNumber":389,"sourceCode":"        }\n\n        Connection connection =\n                DataSourceUtils.getConnection(dataSource.getType(), connectionParam);\n        ResultSet tables = null;\n\n        try {\n\n            if (null == connection) {\n                throw new ServiceException(Status.DATASOURCE_CONNECT_FAILED);\n            }\n\n            DatabaseMetaData metaData = connection.getMetaData();\n            String schema = null;\n            try {\n                schema = metaData.getConnection().getSchema();\n            } catch (SQLException e) {\n                log.error(\"Can not get the schema, datasourceId:{}.\", datasourceId, e);\n                throw new ServiceException(Status.GET_DATASOURCE_TABLES_ERROR);\n            }\n\n            tables = metaData.getTables(\n                    database,\n                    getDbSchemaPattern(dataSource.getType(), schema, connectionParam),\n                    \"%\", TABLE_TYPES);\n            if (null == tables) {\n                log.error(\"Get datasource tables error, datasourceId:{}.\", datasourceId);\n                throw new ServiceException(Status.GET_DATASOURCE_TABLES_ERROR);\n            }\n\n            tableList = new ArrayList<>();\n            while (tables.next()) {\n                String name = tables.getString(TABLE_NAME);\n                tableList.add(name);\n            }\n\n        } catch (Exception e) {","sourceCodeStart":371,"sourceCodeEnd":407,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java#L371-L407","documentation":"getTables throws GET_DATASOURCE_TABLES_ERROR when connection.getMetaData().getConnection().getSchema() raises SQLException while resolving the schema for the datasource. The connection was established but schema introspection failed.","triggerScenarios":"During getTables, metaData.getConnection().getSchema() throws SQLException — e.g. drivers that do not implement getSchema, DB2/Oracle quirks with current schema, or session/state errors on the freshly opened connection.","commonSituations":"Datasource types whose JDBC drivers throw on getSchema(); databases where the connected user has no default schema; driver version incompatibilities with the JDK's schema API.","solutions":["Upgrade the JDBC driver for the datasource type to one that supports getSchema()","Connect with a user that has a default/current schema set","Check the logged exception (datasourceId) to identify the underlying SQLException","If the driver can't support it, avoid the table-browser endpoint for this datasource type"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"try (Connection c = DriverManager.getConnection(url, user, pass)) {\n    c.getSchema(); // fail fast if driver cannot resolve schema\n}","typeGuard":null,"tryCatchPattern":"try {\n    return dataSourceService.getTables(loginUser, datasourceId, database);\n} catch (ServiceException e) {\n    if (Status.GET_DATASOURCE_TABLES_ERROR.getCode() == e.getCode()) { /* check driver getSchema support */ }\n    throw e;\n}","preventionTips":["Use JDBC drivers that implement getSchema() for your datasource type","Connect with a database user that has a default schema","Check server logs (datasourceId is logged) for the root SQLException"],"tags":["jdbc","metadata","sql"],"backgroundTag":"database-query-failed","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}