The connection that is returned will implement the interface CloudSpannerJdbcConnection.
The JDBC connection URL must be specified in the following format:
The project-id part of the URI may be filled with the placeholder DEFAULT_PROJECT_ID. This
placeholder is replaced by the default project id of the environment that is requesting a
connection.
The supported properties are:
credentials (String): URL for the credentials file to use for the connection. If you do not
specify any credentials at all, the default credentials of the environment as returned by
GoogleCredentials#getApplicationDefault() is used.
autocommit (boolean): Sets the initial autocommit mode for the connection. Default is true.
readonly (boolean): Sets the initial readonly mode for the connection. Default is false.
autoConfigEmulator (boolean): Automatically configure the connection to try to connect to
the Cloud Spanner emulator. You do not need to specify any host or port in the connection
string as long as the emulator is running on the default host/port (localhost:9010). The
instance and database in the connection string will automatically be created if these do
not yet exist on the emulator. This means that you do not need to execute any gcloud
commands on the emulator to create the instance and database before you can connect to it.
Setting this property to true also enables running concurrent transactions on the emulator.
The emulator aborts any concurrent transaction on the emulator, and the JDBC driver works
around this by automatically setting a savepoint after each statement that is executed.
When the transaction has been aborted by the emulator and the JDBC connection wants to
continue with that transaction, the transaction is replayed up until the savepoint that had
automatically been set after the last statement that was executed before the transaction
was aborted by the emulator.
endpoint (string): Set this property to specify a custom endpoint that the JDBC driver
should connect to. You can use this property in combination with the autoConfigEmulator
property to instruct the JDBC driver to connect to an emulator instance that uses a
randomly assigned port numer. See ConcurrentTransactionOnEmulatorTest
for a concrete example of how to use this property.
usePlainText (boolean): Sets whether the JDBC connection should establish an unencrypted
connection to the server. This option can only be used when connecting to a local emulator
that does not require an encrypted connection, and that does not require authentication.
optimizerVersion (string): The query optimizer version to use for the connection. The value
must be either a valid version number or LATEST. If no value is specified, the
query optimizer version specified in the environment variable
SPANNER_OPTIMIZER_VERSION is used. If no query optimizer version is specified in the
connection URL or in the environment variable, the default query optimizer version of Cloud
Spanner is used.
oauthtoken (String): A valid OAuth2 token to use for the JDBC connection. The token must
have been obtained with one or both of the scopes
'https://www.googleapis.com/auth/spanner.admin' and/or
'https://www.googleapis.com/auth/spanner.data'. If you specify both a credentials file and
an OAuth token, the JDBC driver will throw an exception when you try to obtain a
connection.
public static final String OPEN_TELEMETRY_PROPERTY_KEY
The info Properties object that is passed to the JDBC driver may contain an entry with
this key and an io.opentelemetry.api.OpenTelemetry instance as its value. This io.opentelemetry.api.OpenTelemetry instance will be used for tracing and metrics in the JDBC
connection.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-30 UTC."],[],[]]