ydb-java-sdk icon indicating copy to clipboard operation
ydb-java-sdk copied to clipboard

There is no convenient way to connect to YDB in Y.Cloud via JDBC using connection url in IDE

Open pnv1 opened this issue 3 years ago • 0 comments

The cause of the problem: Y.Cloud uses iam authentication for all of its services, including YDB. There is a separate project "auth-iam" in YDB SDK repository for iam authentication. YDB core does not depend on it. Neither does JDBC. JDBC has only default token authentication. To use iam authentication in jdbc there is an opportunity to set custom authProvider in the code of a user application. Example: https://github.com/yandex-cloud/ydb-java-sdk/blob/master/jdbc/examples/basic_example/src/main/java/com/yandex/ydb/jdbc/example/Main.java#L46

But when you use JDBC in IDEs all you can set is a connection url with a list of key-value string properties.

Solution: Probably a new jdbc jar that has iam authentication options in connection url.

Workaround: You can get iam token (yc iam create-token) and use it as a token in JDBC's connection url: jdbc:ydb:<endpoint>?database=<database>&token=<iam-token>&secureConnection=true Note that iam-token expires in around 10 hours, so its a temporary solution.

pnv1 avatar Sep 30 '21 12:09 pnv1