flink-connector-jdbc icon indicating copy to clipboard operation
flink-connector-jdbc copied to clipboard

[FLINK-33069]Mysql and Postgres catalog support url extra parameters

Open waywtdcc opened this issue 2 years ago • 6 comments

Mysql and Postgres catalog support url extra parameters

CREATE CATALOG mymysql WITH( 'type' = 'jdbc', 'default-database' = 'test', 'username' = 'root', 'password' = 'xxx', 'base-url' = 'jdbc:mysql://xxx:53309', 'extra-url-param' = '?characterEncoding=utf8' );

If used in this way, the URLs of all tables obtained from this catalog are: jdbc:mysql://xxx:53309?characterEncoding=utf8

waywtdcc avatar Sep 11 '23 05:09 waywtdcc

Thanks for opening this pull request! Please check out our contributing guidelines. (https://flink.apache.org/contributing/how-to-contribute.html)

boring-cyborg[bot] avatar Sep 11 '23 05:09 boring-cyborg[bot]

@MartijnVisser Hello, can you review this PR when you have time?

waywtdcc avatar Oct 18 '23 01:10 waywtdcc

@waywtdcc Why does this need to be an additional parameter?

MartijnVisser avatar Oct 30 '23 10:10 MartijnVisser

@waywtdcc Why does this need to be an additional parameter?

Because sometimes you need to use ?characterEncoding=utf8 similar url parameters to connect to jdbc

waywtdcc avatar Nov 08 '23 05:11 waywtdcc

Because sometimes you need to use ?characterEncoding=utf8 similar url parameters to connect to jdbc

But why not just pass these in to the base URL?

MartijnVisser avatar Nov 08 '23 08:11 MartijnVisser

Because sometimes you need to use ?characterEncoding=utf8 similar url parameters to connect to jdbc

But why not just pass these in to the base URL?

The real url is a combination of base-url+default-database, so I cannot form the correct url when I add it to base-url. For example, if the base-url is set to jdbc:mysql://xxx:53309?characterEncoding=utf8, then the final real url is jdbc:mysql://xxx:53309?characterEncoding=utf8/test; this is the wrong url.

waywtdcc avatar Nov 13 '23 00:11 waywtdcc