Jump to Content

Opening the door to more dev tools for Cloud Spanner

November 6, 2019
Christoph Bussler

Solutions Architect, Google Cloud

We recently released a new native open-source JDBC driver built by Google Cloud Platform (GCP) to enable the easy integration of Cloud Spanner into graphical database development tools. This can be useful for software engineers designing application database schemas in Cloud Spanner, database architects accessing Cloud Spanner, or database administrators monitoring and maintaining Cloud Spanner.

In this blog, we’ll walk through how you can integrate and access your Cloud Spanner databases from DBeaver, a popular open source graphical database development tool. DBeaver lets you browse and edit databases, create and execute SQL scripts, export data, transaction management and ER diagrams. 

Here’s a look at the tool:


In order to access Cloud Spanner from DBeaver, you have to go through the following short process. (This assumes that you have DBeaver installed and at least one Cloud Spanner database created in a GCP project that contains some data.)

  1. Create a self-contained JAR file that includes the open-source JDBC driver and all its dependencies.
  2. Create a database driver in DBeaver.
  3. Create a database connection to your Cloud Spanner instance.
  4. Run Cloud Spanner queries.

1. Create self-contained JAR file
The easiest setup of a database driver in DBeaver is based on a self-contained JAR file that contains the JDBC driver and all its dependencies. One way to create a self-contained JAR file is to create a Maven project with only one dependency:


and execute it with


This Maven command creates a single JAR file that has all dependencies of the JDBC driver resolved and included, like this: spannerjdbc-1.0-SNAPSHOT-jar-with-dependencies.jar.

2. Create a database driver
The next step is to create a database driver in DBeaver. Start DBeaver, select the tab Database, select the drop-down item Driver Manager, and in the window that appears, select New. You’ll see this:


Give the driver a name—for example, CloudSpanner—select Add File in the Libraries tab, and open the JAR file you created in the previous step. Then select the Find Class button that automatically determines the driver class name, and click OK twice. You’ve now defined a Cloud Spanner driver that can be used by database connections.

3. Create a database connection
The last step before executing queries is creating a database connection to a Cloud Spanner database. As before, select the tab Database and select the drop-down menu item New Database Connection. Find and select Cloud Spanner (the name of the database driver you created earlier), and select next>. Enter the JDBC URL (this JDBC documentation shows how the URL is constructed) and test it by selecting Test Connection. If all works fine, you’ll see this:


Select OK, then Finish, and you are ready to go execute queries.

4. Run Cloud Spanner queries
You can execute queries by typing them into the query window and pressing the small orange triangle on the side of the window. The result appears underneath in a result window:


All the functionality of the graphical development tool is now available for you to use with Cloud Spanner. Happy querying!

You can also follow the above steps with other graphical database development tools to get access to your Cloud Spanner databases and issue queries. These steps are similar for the various tools and will serve you as a guidance.

If you already have a database development tool, chances are that it works with the JDBC drivers, and a similar process to the one above should give you access with your development tool of choice: Try it out!

If you do not have a database development tool yet, download and configure one and connect it to your Cloud Spanner database.

Posted in