Skip to content

[bug][PES][datasource] DB2 getAllDatabases() uses invalid command causing schema query failure #5408

Description

@aiceflower

Search before asking

  • I had searched in the issues and found no similar issues.

Linkis Component

  • linkis-commons
  • linkis-computation-governance
  • linkis-dist
  • linkis-engineconn-plugin
  • linkis-extensions
  • linkis-orchestrator
  • linkis-public-enhancements
  • linkis-spring-cloud-services
  • linkis-web

Description

The getAllDatabases() method in DB2 SqlConnection classes uses an invalid command list database directory which is a DB2 CLP (Command Line Processor) command, not a valid SQL query. This causes the schema/database list retrieval to fail when connecting to DB2 data sources via JDBC.

The method should use a proper SQL query against the DB2 system catalog view SYSCAT.SCHEMATA to get the schema list.

Steps to reproduce

  1. Configure a DB2 data source in Linkis
  2. Try to query the database/schema list through the metadata query service
  3. The getAllDatabases() method throws an SQLException because list database directory is not a valid SQL statement for JDBC execution

Expected behavior

The method should successfully return a list of schemas from the DB2 database using a proper SQL query against SYSCAT.SCHEMATA.

Your environment

  • Linkis version used: dev-2.0.0
  • DB2 version: Any DB2 version
  • JDK: 1.8+

Anything else

The fix involves:

  1. Replace invalid list database directory command with proper SQL: SELECT SCHEMANAME FROM SYSCAT.SCHEMATA WITH UR
  2. Add configurable schema query SQL with default filtering system schemas (SYS%, NULLID, SQLJ)
  3. Both linkis-datasource-manager/service/jdbc and linkis-metadata-query/service/jdbc modules need to be fixed

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions