0

Using JDBC client (Squirrel SQL), we have tried to connect to Spanner instance. But we ended up in an issue.​

  • Before experimenting Spanner, we tried to connect AWS aurora mysql DB with Squirrel SQL through mysql JDBC driver. It was successful and we are able to run queries on DB.
  • Cloud spanner JDBC driver has been accepted by Squirrel SQL without any issue.
  • There is a connection error even when all the parameters are fed correctly to the driver.
  • ​As per Spanner's JDBC documentation, host is given as "localhost", it will be used just as a placeholder by squirrel SQL, but JDBC will neglect it.
  • Project ID, instance name and DB name are taken from the cloud spanner instance
  • Connection fails with DNS error.

There is no useful online documentation explaining the usage of spanner's JDBC makes it very difficult to figure out the issue with the connection.

Our concern is with using "localhost" as a base address. But the documentations direct us to do so. https://github.com/olavloite/spanner-jdbc/wiki/URL-and-Connection-Properties

Maxim
  • 4,075
  • 1
  • 14
  • 23
  • What is the exact error message that you get? And do you have an example of the URL you are using? – Knut Olav Løite Jan 23 '18 at 11:31
  • And here is a tutorial on how to use the driver with a number of different database tools (including SQuirreL): http://www.googlecloudspanner.com/2017/10/using-standard-database-tools-with.html – Knut Olav Løite Jan 23 '18 at 11:35

1 Answers1

2

I've just tried it out using the steps in the tutorial found here, and it works: http://www.googlecloudspanner.com/2017/10/using-standard-database-tools-with.html

Possible reasons for your problem could be:

  1. Make sure that your URL or connection properties actually reference an instance AND a database. Both properties are mandatory.
  2. Make sure you supply an authentication key, for example using the URL or connection property PvtKeyPath
  3. Make sure the instance and database that you reference in your URL (or connection properties) actually exist. If you reference an instance or database that does not exist, you will get an exception complaining that the instance or database could not be found (including an URL to that instance/database).

Here's an example of a working URL:

jdbc:cloudspanner://localhost;Project=test-project-123456;Instance=test-instance;Database=test;PvtKeyPath=/home/loite/CloudSpannerKeys/cloudspanner-key.json

Knut Olav Løite
  • 2,964
  • 7
  • 19
  • The class name for the (community) driver is nl.topicus.jdbc.CloudSpannerDriver – James T. Aug 13 '20 at 00:52
  • I omitted the PvtKeyPath key and value from the uri and gave user and pass in the alias settings of my google account for GCP for auth. – James T. Aug 13 '20 at 00:56