public static class ConnectionOptions.Builder extends Object
ConnectionOptions
instances.Modifier and Type | Field and Description |
---|---|
static String |
SPANNER_URI_FORMAT
Spanner
ConnectionOptions URI format. |
Modifier and Type | Method and Description |
---|---|
ConnectionOptions |
build() |
ConnectionOptions.Builder |
setCredentialsUrl(String credentialsUrl)
Sets the URL of the credentials file to use for this connection.
|
ConnectionOptions.Builder |
setOAuthToken(String oauthToken)
Sets the OAuth token to use with this connection.
|
ConnectionOptions.Builder |
setSessionPoolOptions(SessionPoolOptions sessionPoolOptions)
Sets the
SessionPoolOptions to use for the connection. |
ConnectionOptions.Builder |
setUri(String uri)
Sets the URI of the Cloud Spanner database to connect to.
|
public static final String SPANNER_URI_FORMAT
ConnectionOptions
URI format.public ConnectionOptions.Builder setUri(String uri)
cloudspanner:[//host[:port]]/projects/project-id[/instances/instance-id[/databases/database-name]][\?property-name=property-value[;property-name=property-value]*]?The property-value strings should be url-encoded.
The project-id part of the URI may be filled with the placeholder DEFAULT_PROJECT_ID. This placeholder will be replaced by the default project id of the environment that is requesting a connection.
The supported properties are:
setCredentialsUrl(String)
method. If you do not specify any
credentials at all, the default credentials of the environment as returned by GoogleCredentials.getApplicationDefault()
will be used.
CredentialsProvider
that should be used to get credentials for
a connection that is created by this ConnectionOptions
. The credentials will be
retrieved from the CredentialsProvider
when a new
connection is created. A connection will use the credentials that were obtained at
creation during its lifetime.
uri
- The URI of the Spanner database to connect to.public ConnectionOptions.Builder setSessionPoolOptions(SessionPoolOptions sessionPoolOptions)
SessionPoolOptions
to use for the connection.public ConnectionOptions.Builder setCredentialsUrl(String credentialsUrl)
If you do not specify a credentialsUrl (either by using this setter, or by specifying on
the connection URI), the credentials returned by GoogleCredentials.getApplicationDefault()
will be used for the connection.
credentialsUrl
- A valid file or Google Cloud Storage URL for the credentials file to be
used.public ConnectionOptions.Builder setOAuthToken(String oauthToken)
build()
method will throw an
exception.oauthToken
- A valid OAuth token for the Google Cloud project that is used by this
connection.public ConnectionOptions build()
ConnectionOptions
Copyright © 2022 Google LLC. All rights reserved.