Spanner JDBC driver

This page describes the Spanner JDBC driver,which is recommended and authored by Google.

Google offers an open-source JDBC driver for Spanner. The open-sourcedriver enables applications to access Spanner through the Java DatabaseConnectivity (JDBC) API.

This page answers frequently asked questions about the Spanner JDBC driver.To learn how to use the driver, seeConnect JDBC to a GoogleSQL-dialect database.

Data Manipulation Language (DML) and Data Definition Language (DDL) support

The Spanner JDBC driver driver supports DML and DDL statements.

Parent-child and interleaved table relationships

Interleaved table relationships are mapped to foreign key relationships in JDBC.In Spanner, a record in the child table interleaved with a parent hasits primary key dependent on the associated parent table record's primary key.Spanner defines the child table'sparent primary key portion of itsprimary key as the foreign key, referencing the parent table's primary key. Thusyou can navigate the interleaved table relationships using the foreign keymetadata calls inDatabaseMetaData. You can read more details inAbout schemas.

Data types support

The Spanner JDBC driver doesn't support Spanner'sSTRUCTdata type. All other types have appropriate mappings.

Index support

You can use indexes inSELECT queries using the appropriatequery syntax. The open-source driver can alsocreate and modify indexes as DDL statements. You can access information aboutparticular indexes using theDatabaseMetaData.getIndexInfo() method.

Parameterized query support

This driver supports positional parameterization.

Connection pools

The Spanner JDBC driver handles pooling internally by keeping track ofall connections that have been opened, as well as the connection properties thatwere used to open those connections. These pool connections are re-used, forexample, when a new connection is required that has the same connectionproperties as an existing connection. A connection is closed automatically if ithas not been used in the last 60 seconds.

If you want to provide your own pool, you can use any standardJDBC connection pool. Configure the pool to use the driver classcom.google.cloud.spanner.jdbc.JdbcDriver and set a valid SpannerJDBC connection URL.

Limitations

This driver's capabilities have limits defined by the underlying system. See thequotas and limits for Spanner.

Support

Consult oursupport page for support options.

What's next

Learn how toConnect JDBC to a GoogleSQL-dialect database.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.