Google offers an open-source JDBC driver for Spanner. The open-source driver enables applications to access Spanner through the Java Database Connectivity (JDBC) API.
This page answers frequently asked questions about the open-source JDBC driver. To learn how to use the driver, see Using the open-source JDBC driver.
Can I use this driver to issue Data Manipulation Language (DML) and Data Definition Language (DDL) statements?
Yes, this driver supports DML and DDL statements.
How does this driver deal with Spanner parent-child or 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 has
its primary key dependent on the associated parent table record's primary key.
Spanner defines the child table's parent primary key portion of its
primary key as the foreign key, referencing the parent table's primary key. Thus
you can navigate the interleaved table relationships using the foreign key
metadata calls in
DatabaseMetaData. You can read more details in
Schema and data model.
Are all Spanner data types supported by this driver?
The open-source JDBC driver does not support Spanner's
type. All other types have appropriate mappings.
Does this driver support indexes?
Yes. You can use indexes in
SELECT queries using the appropriate
query syntax. The open-source driver can also
create and modify indexes as DDL statements. You can access information about
particular indexes using the
Does this driver support parameterized queries?
Yes, this driver supports positional parameterization.
Do I need to provide my own connection pool?
The open-source JDBC driver handles pooling internally by keeping track of all connections that have been opened, as well as the connection properties that were used to open those connections. These pool connections are re-used, for example, when a new connection is required that has the same connection properties as an existing connection. A connection is closed automatically if it has not been used in the last 60 seconds.
If you want to provide your own pool, you can use any standard
JDBC connection pool. Configure the pool to use the driver class
com.google.cloud.spanner.jdbc.JdbcDriver and set a valid Spanner
JDBC connection URL.
Are there other limitations to consider when using this driver?
This driver's capabilities have limits defined by the underlying system. See the quotas and limits for Spanner.
How do I get support for this driver?
Consult our support page for support options.