jinkachy opened a new pull request, #8986:
URL: https://github.com/apache/seatunnel/pull/8986
# [Fix][Connector] Fix JDBC driver selection for data source connections
<!--
Thank you for contributing to SeaTunnel! Please make sure that your code
changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
## Contribution Checklist
- Make sure that the pull request corresponds to a [GITHUB
issue](https://github.com/apache/seatunnel/issues).
- Name the pull request in the form "[Feature] [component] Title of the
pull request", where *Feature* can be replaced by `Hotfix`, `Bug`, etc.
- Minor fixes should be named following this pattern: `[hotfix] [docs] Fix
typo in README.md doc`.
-->
### Purpose of this pull request
This pull request fixes an issue with JDBC driver selection when dealing
with heterogeneous data sources. In the current implementation, DriverManager
may select the wrong driver when multiple compatible drivers are available in
the classpath. This can cause problems when transferring data between similar
databases (like Greenplum to PostgreSQL or MySQL 5 to MySQL 8), where driver
"drift" can occur.
The fix explicitly finds and uses the driver specified by class name before
falling back to the default DriverManager behavior, ensuring that the correct
driver is used for the connection.
### Does this PR introduce _any_ user-facing change?
This PR improves the reliability of JDBC connections when working with
heterogeneous data sources, but doesn't change any user-facing API or
configuration. Users may notice improved stability when transferring data
between similar database systems that require different drivers.
### How was this patch tested?
The implementation was tested with various database connections where driver
drift could occur, particularly focusing on:
- MySQL 5 to MySQL 8 connections
- PostgreSQL to Greenplum connections
- Multiple JDBC drivers in the classpath
The tests verified that the correct driver is selected when explicitly
specified, even when multiple compatible drivers are available.
### Check list
* [x] The main modification is an improvement to the
`org.apache.seatunnel.connectors.seatunnel.jdbc.catalog.AbstractJdbcCatalog#getConnection`
method, prioritizing the use of the specified driver class to establish
connections and avoid driver drift issues
* [x] Related changes include ensuring the `driverClass` parameter is
correctly passed to the getConnection method, allowing the specified driver
priority to take effect
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]