Google Spanner:JDBC连接字符串? [英] Google Spanner: JDBC Connection Strings?

查看:95
本文介绍了Google Spanner:JDBC连接字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尽管Spanner看起来令人兴奋,但Simba JDBC驱动程序的文档(包含在此处的下载链接中:

While Spanner looks exciting, the documentation for the Simba JDBC driver (included in the download links here: https://cloud.google.com/spanner/docs/partners/drivers) are relatively sparse, especially when compared to the documentation for the Simba JDBC BigQuery driver (https://cloud.google.com/bigquery/partners/simba-drivers/).

特别是,文档仅提及一个连接字符串:

In particular, the documentation only mentions one connection string:

jdbc:cloudspanner://localhost;Project=simba-cloudspanner- jdbc;Instance=test-instance;Database=example-db

...没有有关如何指定例如许多Google Cloud服务使用的服务帐户及其p12凭据或JSON文件路径的信息.

... there is no information about how to specify, for example, a service account and its p12 credentials or a path to a JSON file, which many Google Cloud services use.

任何人都可以共享已成功用于连接服务的JDBC连接字符串或其他设置详细信息吗?例如,我尝试设置环境变量GOOGLE_APPLICATION_CREDENTIALS并提供与上述样式相同的JDBC字符串,但无济于事.

Can anyone share JDBC connection strings or other setup details they have successfully used to connect to the service? I have tried, for example, setting the environment variable GOOGLE_APPLICATION_CREDENTIALS and providing a JDBC string in the same style as above, but to no avail.

理想情况下,我想结合使用实例ID,项目名称,数据库名称,服务帐户电子邮件和p12文件,但是可以使用其他身份验证选项.

Ideally, I would like to use a combination of instance id, project name, database name, a service account email, and a p12 file, but am open to other authentication options.

尝试GOOGLE_APPLICATION_CREDENTIALS策略时,我会生成此日志文件,以防可能有所帮助 https://gist.github.com/aryeh-looker/e6b1b1617d301f0a247463216c96535d

When attempting the GOOGLE_APPLICATION_CREDENTIALS strategy, I generated this log file, in case it might be of any help https://gist.github.com/aryeh-looker/e6b1b1617d301f0a247463216c96535d

推荐答案

仔细检查了我的工作,看来我 am 实际上能够与上述连接字符串连接并通过设置环境变量GOOGLE_APPLICATION_CREDENTIALS.拥有其他一些选择将是理想的选择,并且文档仍然有些参差不齐(不提及环境变量),因此更多的信息可能是理想的.

Double-checked my work, and it looks like I am in fact able to connect with a connection string as above and by setting the environment variable GOOGLE_APPLICATION_CREDENTIALS. Would be ideal to have some other options and documentation is still a bit spotty (no mention of the environment variable), so more information could be ideal.

这是一个半可行的解决方案.遭受这样一个事实,即您不能在同一过程中与不同的服务帐户建立多个连接.

This is a semi-workable solution. It suffers from the fact that you cannot have multiple connections with different service accounts in the same process.

这似乎不起作用.指向JSON文件时,我收到有关未指定实例的错误.

EDIT 2: This does not seem to work. I get errors about the instance not being specified when pointing to a JSON file.

看起来像最新版本的Spanner驱动程序一样,有一种方法可以实现.

looks like with the latest release of the Spanner driver, there is a way to do this.

驱动程序的最新版本(1.0.4.1005)似乎支持可选的JDBC参数PvtKeyPath,该参数采用到私钥的路径,而不必设置GOOGLE_APPLICATION_CREDENTIALS变量.值得一看.

The latest release of the driver (1.0.4.1005) appears to support an optional JDBC parameter PvtKeyPath which takes a path to your private key as opposed to having to set the GOOGLE_APPLICATION_CREDENTIALS variable. Worth a look.

从随附的PDF文档中:

From the included PDF documentation:

因此,您将拥有一个类似于jdbc:cloudspanner://;Project=...;PvtKeyPath=/path/to/credentials.json

So you will have a URL like: jdbc:cloudspanner://;Project=...;PvtKeyPath=/path/to/credentials.json

这篇关于Google Spanner:JDBC连接字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆