问题
I have tried this isn DBeaver and DataGrip.
Running with the Google Spanner Emulator locally (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
Will this work with the Google JDBC Spanner Driver?
In my testing, my guess is:
No this is not currently supported.
I can manage to connect to a GCP instance of spanner, but not the emulator. When I try with port 9010 or 9020 it basically hangs.
My jdbc connection strings are as follows (the project, instance and the database have all been created):
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
回答1:
The emulator does not use TLS, while the JDBC driver will use that by default. You can turn off TLS for the JDBC driver by setting the usePlainText
connection property to true
. The following connection URL should work:
jdbc:cloudspanner://localhost:9010/projects/local-project/instances/local-instance/databases/myDatabase?usePlainText=true
来源:https://stackoverflow.com/questions/62971749/does-the-google-spanner-emulator-work-with-the-google-spanner-jdbc-driver