[ 
https://issues.apache.org/jira/browse/FLINK-20657?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17252450#comment-17252450
 ] 

Kezhu Wang commented on FLINK-20657:
------------------------------------

I see {{SimpleJdbcConnectionProvider}} has been shaped as some kind of 
container of established connection, so I propose to add 
{{SimpleJdbcConnectionProvider.closeConnection}} otherwise it is not possible 
to clear {{SimpleJdbcConnectionProvider.connection}}. Another direction is 
providing factory-like method 
{{SimpleJdbcConnectionProvider.createConnection}}. {{PostgresCatalog}} may need 
this as it has multiple ephemeral connections for different databases if it 
take {{driverName}} into account and migrate to 
{{SimpleJdbcConnectionProvider}} finally. In that stage, 
{{JdbcConnectionProvider}} could extend an new interface 
{{JdbConnectionFactory}} to provide that functionality.

Besides this, is there any reason why we need {{synchronized(this)}} in 
{{SimpleJdbcConnectionProvider.getConnection}} ? Should we drop it ?

[~roman_khachatryan] [~jark] What do you think ? Could you mind assign this to 
me if above sounds good to you ?

> Migrate jdbc connection code of JdbcInputFormat, JdbcLookupFunction, 
> JdbcRowDataLookupFunction to SimpleJdbcConnectionProvider
> ------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: FLINK-20657
>                 URL: https://issues.apache.org/jira/browse/FLINK-20657
>             Project: Flink
>          Issue Type: Improvement
>          Components: Connectors / JDBC, Table SQL / Ecosystem
>    Affects Versions: 1.13.0
>            Reporter: Kezhu Wang
>            Priority: Major
>
> Currently, there are multiple places to establish jdbc connection, several of 
> them were written before introducing of {{JdbcConnectionProvider}} in 
> FLINK-15782. We need to migrate these classes for reasons:
> * Code reusability.
> * Circumvent pitfalls of {{DriverManager}} such as FLINK-19435 and possible 
> [others|https://ci.apache.org/projects/tomcat/tomcat85/docs/jndi-datasource-examples-howto.html#DriverManager,_the_service_provider_mechanism_and_memory_leaks]
>  in one place.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to