Skip to content

[fix][EC][jdbc] Add configurable validation query for different database types#5412

Merged
casionone merged 3 commits intoapache:masterfrom
aiceflower:pr-20260412-jdbc-validation-query
Apr 13, 2026
Merged

[fix][EC][jdbc] Add configurable validation query for different database types#5412
casionone merged 3 commits intoapache:masterfrom
aiceflower:pr-20260412-jdbc-validation-query

Conversation

@aiceflower
Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

This PR adds configurable validation query support for JDBC engine connection pool, enabling proper connection validation for Oracle, DB2, and other databases that require non-standard validation queries.

Changes:

  1. ConnectionManager.java: Added validation query mapping logic that auto-detects database type from JDBC URL and selects appropriate validation query
  2. JDBCEngineConnConstant.java: Added new configuration constant for validation query mapping
  3. JDBCConfiguration.scala: Added configuration item with default support for Oracle and DB2
  4. distribution.xml: Excluded conflicting jars from JDBC plugin assembly packaging

Why are the changes needed?

JDBC engine connection pool uses "SELECT 1" as the default validation query, which works for MySQL and PostgreSQL but fails for:

  • Oracle: requires "SELECT 1 FROM DUAL"
  • DB2: requires "SELECT 1 FROM SYSIBM.SYSDUMMY1"

Fixes #5411

How was this patch tested?

  • Oracle database connection pool validation test
  • DB2 database connection pool validation test
  • MySQL/PostgreSQL default validation query compatibility test
  • JDBC plugin assembly packaging test (no jar conflicts)

Does this PR introduce any user-facing change?

Yes, users can now configure database-specific validation queries via:

# Format: dbType1:query1,dbType2:query2,...
wds.linkis.jdbc.validation.query.mapping=oracle:SELECT 1 FROM DUAL,db2:SELECT 1 FROM SYSIBM.SYSDUMMY1

How was this patch tested?

  • Verified connection pool initialization with Oracle JDBC URL
  • Verified connection pool initialization with DB2 JDBC URL
  • Verified backward compatibility with MySQL/PostgreSQL

Check List

  • Update License info if needed
  • Add new UT/IT if needed
  • Need to update docs
  • Need to add warning banner in README

aiceflower and others added 3 commits April 12, 2026 22:42
…nection pool

- Add DB2-specific validation query "SELECT 1 FROM SYSIBM.SYSDUMMY1"
- Same pattern as existing Oracle validation query handling
- Fixes DB2 connection pool validation error when using datasource name

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Exclude Jetty jars to avoid version conflicts with public-module
- Exclude SLF4J bindings to prevent multiple binding errors
- Exclude Hadoop jars to use shared public-module versions

These exclusions prevent class loading conflicts when JDBC engine
starts and uses jars from both plugin lib and public-module.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…t database types

- Add configuration parameter 'wds.linkis.jdbc.validation.query.mapping'
- Default mapping: oracle:SELECT 1 FROM DUAL,db2:SELECT 1 FROM SYSIBM.SYSDUMMY1
- Remove hardcoded database-specific validation query logic
- To add new database type, just update configuration, no code change needed

Benefits:
- Configuration-driven approach for extensibility
- Easy to add support for new databases without modifying source code
- Default values work for most common databases

Usage example:
  Add to linkis-engineconn.properties:
  wds.linkis.jdbc.validation.query.mapping=oracle:SELECT 1 FROM DUAL,db2:SELECT 1 FROM SYSIBM.SYSDUMMY1,postgresql:SELECT 1

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@casionone casionone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@casionone casionone merged commit d527f20 into apache:master Apr 13, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug][EC][jdbc] JDBC connection pool validation query fails for Oracle and DB2 databases

2 participants