Note: There is now a Google backed open source JDBC driver for Google Cloud Spanner. It is recommended that you use that driver. It can be found here: https://github.com/googleapis/java-spanner-jdbc
This community driver will continue to exist in its current form. It will however not implement any new features that Cloud Spanner might add in the future.
Community Open Source JDBC Driver for Google Cloud Spanner
Include the following if you want the thick jar version that includes all (shaded) dependencies. This is the recommended version unless you know that the transitive dependencies of the small jar will not conflict with the rest of your project.
<dependency>
<groupId>nl.topicus</groupId>
<artifactId>spanner-jdbc</artifactId>
<version>1.1.6</version>
</dependency>
Downloads for both the current and older versions can be found here: https://github.com/olavloite/spanner-jdbc/releases
Building your own version can be done using:
mvn install -DskipITs
(See the section Building for more information on this)
This driver can be used with JPA and Hibernate. It is however recommended to use the officially supported driver at https://github.com/googleapis/java-spanner-jdbc in combination with the officially supported Hibernate dialect.
The driver is by default a 'thick' jar that contains all the dependencies it needs. The dependencies are shaded to avoid any conflicts with dependencies you might use in your own project. Shading and adding the dependencies to the jar is linked to the post-integration-test
phase of Maven. This means that you could build both a thin and a thick jar to use with your project, but please be aware that only the thick jar version is supported. If you decide to use the thin jar you need to supply the dependencies yourself.
mvn install -DskipITs
Skipping the integration tests while building is necessary as these will try to connect to a default Cloud Spanner instance (or Cloud Spanner emulator) to run the tests on. The key file for authenticating on these default instances are not included in the source code.
mvn package
This will give you a jar containing only the compiled source of the JDBC driver without the necessary dependencies. You will have to supply these yourself. This is not the recommended way of using the driver, unless you know what you are doing.
This application uses Open Source components. You can find the source code of their open source projects along with license information below.
A special thanks to Tobias for his great JSqlParser library. Project: JSqlParser https://github.com/JSQLParser/JSqlParser Copyright (C) 2004 - 2017 JSQLParser Tobias