Skip to content
Knut Olav Løite edited this page Jan 1, 2018 · 8 revisions

Frequently Asked Questions

Does the driver support Data Manipulation Language statements (insert, update, delete)?

Yes, the driver does support these, although because of the underlying limits of Google Cloud Spanner, it only supports manipulation operations operating on one row at a time. Bulk DML statements are translated into a combination of a SELECT-statement that retrieves the data that should be inserted/updated/deleted, and a series of single-row mutations actually updating the data.

INSERT statements specifying a single 'VALUES (...)' specification are sent directly to the database

UPDATE and DELETE statements specifying a WHERE primary-key=:value clause are also sent directly to the database. The primary-key could consist of multiple columns.

Bulk INSERT statements are translated into a SELECT that retrieves the data to be inserted, and then a series of single-row insert statements:

INSERT INTO table  
(COL1, COL2, ...)  
SELECT COL1, COL2, ...  
FROM other_table  
WHERE COL3>? AND COL4=?  

Bulk INSERT statements can be used in combination with ON DUPLICATE KEY UPDATE to create an INSERT-OR-UPDATE statement:

INSERT INTO table  
(COL1, COL2, ...)  
SELECT COL1, COL2, ...  
FROM table  
WHERE COL3>? AND COL4=?  
ON DUPLICATE KEY UPDATE  

Does the driver support transactions?

Yes, normal JDBC transactions are supported. Please note that because of the way Cloud Spanner treats transactions, write operations during a transaction are buffered client side and only sent to the database at commit time. This means that write operations are also not visible for the running transaction before commit.

Does the driver support distributed transactions (XA transactions)?

Yes, as of version 0.20 distributed transactions are supported. This feature should currently be considered a beta feature. Please report any issues you might encounter with it. Google Cloud Spanner itself does not support prepared transactions and two-phase commit, so the driver has to simulate this by creating a table that temporarily stores prepared mutations before the actual commit.

Can I use the driver with tools like DBeaver / DBVisualizer / SQuirreL / Safe FME etc?

Yes, the driver can be used with third-party tools to access a Google Cloud Spanner database. Because the underlying Google Cloud Spanner API is used by the driver, and this API does some dynamic service loading, you sometimes need to place the driver in special folders.
Have a look here for a description on how to configure it for some popular products: http://www.googlecloudspanner.com/2017/10/using-standard-database-tools-with.html

DBVisualizer

Follow these steps to use the driver with DBVisualizer:

  1. Download the driver with dependencies (https://github.com/olavloite/spanner-jdbc/releases) and place it in your JRE/lib/ext directory (this is necessary because of dynamic loading of services done by the underlying Google Cloudspanner API). Make sure you place it in the lib/ext directory of the JRE you are actually using with DBVisualizer.
  2. Open DBVisualizer and open Driver Manager. Click on Create a new Driver.
  3. Give it the name Cloudspanner
  4. URL format is jdbc:cloudspanner://localhost;Project=projectId;Instance=instanceId;Database=databaseName;PvtKeyPath=key_file
  5. Driver class is automatically selected.
  6. Close the Driver Manager and make a new connection using the new driver.

SQuirreL

Follow these steps to use the driver with SQuirreL:

  1. Download the driver with dependencies (https://github.com/olavloite/spanner-jdbc/releases) and place it in the /lib directory of your SQuirreL install.
  2. Open SQuirreL and click on the menu item Drivers | New Driver...
  3. Click on the button List Drivers in the popup window. The CloudSpannerDriver should automatically be found.
  4. Give the driver a name (CloudSpanner) and optionally enter an example URL.
  5. Click on OK and you are ready to create a connection using the CloudSpannerDriver.