[
https://issues.apache.org/jira/browse/FLINK-19435?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17245245#comment-17245245
]
Kezhu Wang commented on FLINK-19435:
------------------------------------
[~jark] I am willing to take over this.
Currently, {{driverName}} plays nothing except class loading, I think it is ok
to omit {{Class.forName}} without breaking existing code.
But I saw {{JdbcDialect.defaultDriverName}}, I am wondering whether we proposed
to provide a strong guarantee to clients that a driver with class name
{{driverName}} will be used to handle jdbc connection if provided. If this is
the case, simply dropping {{driverName}} may cause rollback in future. This
could be useful if clients want to switch between different drivers for one
database. But this will also complicate things much because of reasons: 1), all
connection-establishing code will need to take care of this, for example
{{PostgresCatalog}} may need handle this well; 2), jdbc connector need be
driver-agnostic(or support all possible drivers) to achieve this. I am not sure
whether this is an reasonable use case to keep {{driverName}}. If this driver
level customization is not desired, then {{JdbcDialect.defaultDriverName}} is
useless.
Besides this, though {{driverName}} is not direct accessible from sql clients,
but it is an required field in {{JdbcConnectionOptions}} which is
{{PublicEvolving}}. And if we want make that field optional, we need change
signature of {{getDriverName}} according to [coding
style|https://flink.apache.org/contributing/code-style-and-quality-java.html#java-optional]
which is an API breaking operation.
> jdbc JDBCOutputFormat open function invoke Class.forName(drivername)
> --------------------------------------------------------------------
>
> Key: FLINK-19435
> URL: https://issues.apache.org/jira/browse/FLINK-19435
> Project: Flink
> Issue Type: Improvement
> Components: Connectors / JDBC
> Affects Versions: 1.10.2
> Reporter: xiaodao
> Priority: Major
> Fix For: 1.13.0, 1.12.1
>
> Attachments: image-2020-10-09-20-48-48-261.png,
> image-2020-10-09-20-49-23-644.png
>
>
> when we sink data to multi jdbc outputformat ,
> {code}
> protected void establishConnection() throws SQLException,
> ClassNotFoundException {
> Class.forName(drivername);
> if (username == null) {
> connection = DriverManager.getConnection(dbURL);
> } else {
> connection = DriverManager.getConnection(dbURL, username, password);
> }
> }
> {code}
> may cause jdbc driver deadlock. it need to change to synchronized function.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)