[ https://issues.apache.org/jira/browse/FLINK-17294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17088757#comment-17088757 ]
Lijie Wang edited comment on FLINK-17294 at 4/21/20, 2:56 PM: -------------------------------------------------------------- Hi [~jark] , thanks for comments. I think we shouldn't use a long standing connection. Because the database has idle timeout, once the connection is idle for a long time, the database will close the connection. And I found an issue about it. I think it's better to use the connection pool, get connection from the connection pool per transaction begin, and return it back to the connection pool after transaction finish. Connection pool ensure that we can get connection with low overhead, because the connection pool maintains physical connections to the database all the way. And If there are multiple tasks in one task manager, they can reuse the connections in the same connection pool. was (Author: wanglijie95): I think we shouldn't use a long standing connection. Because the database has idle timeout, once the connection is idle for a long time, the database will close the connection. And I found an issue about it. I think it's better to use the connection pool, get connection from the connection pool per transaction begin, and return it back to the connection pool after transaction finish. Connection pool ensure that we can get connection with low overhead, because the connection pool maintains physical connections to the database all the way. And If there are multiple tasks in one task manager, they can reuse the connections in the same connection pool. > Using "DataSource" instead of "DriverManager" to get connection in JDBC > connector > --------------------------------------------------------------------------------- > > Key: FLINK-17294 > URL: https://issues.apache.org/jira/browse/FLINK-17294 > Project: Flink > Issue Type: Improvement > Components: Connectors / JDBC > Reporter: Lijie Wang > Priority: Major > > I noticed that JDBC connector using DriverManager to get connection, but > DataSource is encouraged now. We should using DataSource instead of > DriverManager. > About the DriverManager vs DataSource, see > https://stackoverflow.com/questions/15198319/why-do-we-use-a-datasource-instead-of-a-drivermanager. > Some implementations of DataSource maybe we can use : alibaba durid, apache > dbcp > And we should introduce connection pool to get more performance. -- This message was sent by Atlassian Jira (v8.3.4#803005)