【问题标题】:Does the Google Spanner Emulator work with the Google Spanner JDBC Driver?Google Spanner 模拟器是否可以与 Google Spanner JDBC 驱动程序一起使用?
【发布时间】:2020-07-18 17:39:09
【问题描述】:

我试过这是DBeaverDataGrip

在本地使用 Google Spanner 模拟器运行 (0.8.0)

export SPANNER_EMULATOR_HOST=localhost:9010

Executing: docker run -p 127.0.0.1:9010:9010 -p 127.0.0.1:9020:9020 gcr.io/cloud-spanner-emulator/emulator:0.8.0
[cloud-spanner-emulator] 2020/07/17 22:23:21 gateway.go:135: Cloud Spanner emulator running.
[cloud-spanner-emulator] 2020/07/17 22:23:21 gateway.go:136: REST server listening at 0.0.0.0:9020
[cloud-spanner-emulator] 2020/07/17 22:23:21 gateway.go:137: gRPC server listening at 0.0.0.0:9010

这是否适用于Google JDBC Spanner Driver

在我的测试中,我的猜测是:

不,目前不支持。

我可以设法连接到扳手的 GCP 实例,但不能连接到模拟器。当我尝试使用端口 9010 或 9020 时,它基本上会挂起。

我的jdbc连接字符串如下(项目、实例和数据库都已创建):

gcloud spanner databases list --project=local-project --instance=local-instance --configuration=spanner-emulator --format json

[
  {
    "name": "projects/local-project/instances/local-instance/databases/myDatabase",
    "state": "READY"
  },
]
# 9010
jdbc:cloudspanner://localhost:9010/projects/local-project/instances/local-instance/databases/myDatabase

# 9020
jdbc:cloudspanner://localhost:9020/projects/local-project/instances/local-instance/databases/myDatabase

# just the host
jdbc:cloudspanner://localhost/projects/local-project/instances/local-instance/databases/myDatabase

【问题讨论】:

    标签: google-cloud-spanner


    【解决方案1】:

    模拟器不使用 TLS,而 JDBC 驱动程序将默认使用它。您可以通过将usePlainText 连接属性设置为true 来关闭JDBC 驱动程序的TLS。以下连接 URL 应该可以工作:

    jdbc:cloudspanner://localhost:9010/projects/local-project/instances/local-instance/databases/myDatabase?usePlainText=true
    

    【讨论】:

      猜你喜欢
      • 2017-12-03
      • 1970-01-01
      • 2017-07-05
      • 2017-10-24
      • 2019-07-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-28
      相关资源
      最近更新 更多