diff --git a/.github/readme/synth.metadata/synth.metadata b/.github/readme/synth.metadata/synth.metadata index 109d30036..7cd540889 100644 --- a/.github/readme/synth.metadata/synth.metadata +++ b/.github/readme/synth.metadata/synth.metadata @@ -4,14 +4,14 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-spanner-jdbc.git", - "sha": "37023b8295c97304aa0a55a28f71905fcbf5b93f" + "sha": "68125c4d896a24f186d90648d3be64b5ad15aa37" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "39652e3948f455fd0b77535a0145eeec561a3706" + "sha": "3d32990b6f4b57be77455e3ca89e6e21cd0c06b3" } } ] diff --git a/CHANGELOG.md b/CHANGELOG.md index 55b6ee374..9ffbaac49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## [2.3.0](https://www.github.com/googleapis/java-spanner-jdbc/compare/v2.2.6...v2.3.0) (2021-08-11) + + +### Features + +* add support for tagging to JDBC connection ([#270](https://www.github.com/googleapis/java-spanner-jdbc/issues/270)) ([a4bd82c](https://www.github.com/googleapis/java-spanner-jdbc/commit/a4bd82c8e4ce8b7179b943ac06b049598276f1b4)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2 ([#544](https://www.github.com/googleapis/java-spanner-jdbc/issues/544)) ([366430d](https://www.github.com/googleapis/java-spanner-jdbc/commit/366430dc270edd09de1a0749ba360f312897b1aa)) +* update dependency com.google.cloud:google-cloud-spanner-bom to v6.10.0 ([#537](https://www.github.com/googleapis/java-spanner-jdbc/issues/537)) ([8655ae5](https://www.github.com/googleapis/java-spanner-jdbc/commit/8655ae5955f5385a9d6445e13264427d73c4d37e)) + ### [2.2.6](https://www.github.com/googleapis/java-spanner-jdbc/compare/v2.2.5...v2.2.6) (2021-07-06) diff --git a/README.md b/README.md index a35c7eee8..7486c06df 100644 --- a/README.md +++ b/README.md @@ -8,33 +8,41 @@ Java idiomatic client for [Google Cloud Spanner JDBC][product-docs]. - [Product Documentation][product-docs] - [Client Library Documentation][javadocs] + ## Quickstart If you are using Maven, add this to your pom.xml file: + ```xml com.google.cloud google-cloud-spanner-jdbc - 2.2.5 + 2.2.6 ``` If you are using Gradle without BOM, add this to your dependencies + ```Groovy -compile 'com.google.cloud:google-cloud-spanner-jdbc:2.2.5' +compile 'com.google.cloud:google-cloud-spanner-jdbc:2.2.6' ``` If you are using SBT, add this to your dependencies + ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-spanner-jdbc" % "2.2.5" +libraryDependencies += "com.google.cloud" % "google-cloud-spanner-jdbc" % "2.2.6" ``` ## Authentication See the [Authentication][authentication] section in the base directory's README. +## Authorization + +The client application making API calls must be granted [authorization scopes][auth-scopes] required for the desired Google Cloud Spanner JDBC APIs, and the authenticated principal must have the [IAM role(s)][predefined-iam-roles] required to access GCP resources using the Google Cloud Spanner JDBC API calls. + ## Getting Started ### Prerequisites @@ -128,16 +136,57 @@ activate the `shade` profile like this: To get help, follow the instructions in the [shared Troubleshooting document][troubleshooting]. -## Java Versions +## Supported Java Versions Java 8 or above is required for using this client. +Google's Java client libraries, +[Google Cloud Client Libraries][cloudlibs] +and +[Google Cloud API Libraries][apilibs], +follow the +[Oracle Java SE support roadmap][oracle] +(see the Oracle Java SE Product Releases section). + +### For new development + +In general, new feature development occurs with support for the lowest Java +LTS version covered by Oracle's Premier Support (which typically lasts 5 years +from initial General Availability). If the minimum required JVM for a given +library is changed, it is accompanied by a [semver][semver] major release. + +Java 11 and (in September 2021) Java 17 are the best choices for new +development. + +### Keeping production systems current + +Google tests its client libraries with all current LTS versions covered by +Oracle's Extended Support (which typically lasts 8 years from initial +General Availability). + +#### Legacy support + +Google's client libraries support legacy versions of Java runtimes with long +term stable libraries that don't receive feature updates on a best efforts basis +as it may not be possible to backport all patches. + +Google provides updates on a best efforts basis to apps that continue to use +Java 7, though apps might need to upgrade to current versions of the library +that supports their JVM. + +#### Where to find specific information + +The latest versions and the supported Java versions are identified on +the individual GitHub repository `github.com/GoogleAPIs/java-SERVICENAME` +and on [google-cloud-java][g-c-j]. + ## Versioning This library follows [Semantic Versioning](http://semver.org/). + ## Contributing @@ -149,6 +198,7 @@ Please note that this project is released with a Contributor Code of Conduct. By this project you agree to abide by its terms. See [Code of Conduct][code-of-conduct] for more information. + ## License Apache 2.0 - See [LICENSE][license] for more information. @@ -180,6 +230,9 @@ Java is a registered trademark of Oracle and/or its affiliates. [maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-spanner-jdbc.svg [maven-version-link]: https://search.maven.org/search?q=g:com.google.cloud%20AND%20a:google-cloud-spanner-jdbc&core=gav [authentication]: https://github.com/googleapis/google-cloud-java#authentication +[auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes +[predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles +[iam-policy]: https://cloud.google.com/iam/docs/overview#cloud-iam-policy [developer-console]: https://console.developers.google.com/ [create-project]: https://cloud.google.com/resource-manager/docs/creating-managing-projects [cloud-sdk]: https://cloud.google.com/sdk/ @@ -191,3 +244,9 @@ Java is a registered trademark of Oracle and/or its affiliates. [libraries-bom]: https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/The-Google-Cloud-Platform-Libraries-BOM [shell_img]: https://gstatic.com/cloudssh/images/open-btn.png + +[semver]: https://semver.org/ +[cloudlibs]: https://cloud.google.com/apis/docs/client-libraries-explained +[apilibs]: https://cloud.google.com/apis/docs/client-libraries-explained#google_api_client_libraries +[oracle]: https://www.oracle.com/java/technologies/java-se-support-roadmap.html +[g-c-j]: http://github.com/googleapis/google-cloud-java diff --git a/clirr-ignored-differences.xml b/clirr-ignored-differences.xml index ac9c147d1..0962d5e12 100644 --- a/clirr-ignored-differences.xml +++ b/clirr-ignored-differences.xml @@ -111,4 +111,26 @@ com/google/cloud/spanner/jdbc/CloudSpannerJdbcConnection void setReturnCommitStats(boolean) + + + + 7012 + com/google/cloud/spanner/jdbc/CloudSpannerJdbcConnection + java.lang.String getTransactionTag() + + + 7012 + com/google/cloud/spanner/jdbc/CloudSpannerJdbcConnection + void setTransactionTag(java.lang.String) + + + 7012 + com/google/cloud/spanner/jdbc/CloudSpannerJdbcConnection + java.lang.String getStatementTag() + + + 7012 + com/google/cloud/spanner/jdbc/CloudSpannerJdbcConnection + void setStatementTag(java.lang.String) + diff --git a/java.header b/java.header index 3a9b503aa..d0970ba7d 100644 --- a/java.header +++ b/java.header @@ -1,5 +1,5 @@ ^/\*$ -^ \* Copyright \d\d\d\d,? Google (Inc\.|LLC)( All [rR]ights [rR]eserved\.)?$ +^ \* Copyright \d\d\d\d,? Google (Inc\.|LLC)$ ^ \*$ ^ \* Licensed under the Apache License, Version 2\.0 \(the "License"\);$ ^ \* you may not use this file except in compliance with the License\.$ diff --git a/pom.xml b/pom.xml index bb116a07e..789a4b77c 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 google-cloud-spanner-jdbc - 2.2.6 + 2.3.0 jar Google Cloud Spanner JDBC https://github.com/googleapis/java-spanner-jdbc @@ -14,7 +14,7 @@ com.google.cloud google-cloud-shared-config - 0.12.0 + 1.0.0 @@ -40,16 +40,7 @@ https://github.com/googleapis/java-spanner-jdbc/issues GitHub Issues - - - sonatype-nexus-snapshots - https://oss.sonatype.org/content/repositories/snapshots - - - sonatype-nexus-staging - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - + Apache-2.0 @@ -71,14 +62,14 @@ com.google.cloud google-cloud-spanner-bom - 6.9.1 + 6.10.0 pom import com.google.cloud google-cloud-shared-dependencies - 1.4.0 + 2.0.1 pom import @@ -163,6 +154,12 @@ truth ${truth.version} test + + + org.checkerframework + checker-qual + + org.hamcrest diff --git a/renovate.json b/renovate.json index 4ac4d97c6..a95a109bd 100644 --- a/renovate.json +++ b/renovate.json @@ -69,5 +69,8 @@ } ], "semanticCommits": true, - "masterIssue": true + "dependencyDashboard": true, + "dependencyDashboardLabels": [ + "type: process" + ] } diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index d83d18a54..6c2c269e8 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -29,7 +29,7 @@ com.google.cloud google-cloud-spanner-jdbc - 2.2.4 + 2.2.6 diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index e4893ca51..6f757a592 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -28,7 +28,7 @@ com.google.cloud google-cloud-spanner-jdbc - 2.2.6 + 2.3.0 diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index 39610eebb..23c5d00e8 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -30,7 +30,7 @@ com.google.cloud libraries-bom - 20.7.0 + 20.9.0 pom import diff --git a/src/main/java/com/google/cloud/spanner/jdbc/CloudSpannerJdbcConnection.java b/src/main/java/com/google/cloud/spanner/jdbc/CloudSpannerJdbcConnection.java index 4a5f001a8..50ae71c56 100644 --- a/src/main/java/com/google/cloud/spanner/jdbc/CloudSpannerJdbcConnection.java +++ b/src/main/java/com/google/cloud/spanner/jdbc/CloudSpannerJdbcConnection.java @@ -39,6 +39,47 @@ */ public interface CloudSpannerJdbcConnection extends Connection { + /** + * Sets the transaction tag to use for the current transaction. This method may only be called + * when in a transaction, and before the transaction is actually started, i.e. before any + * statements have been executed in the transaction. + * + *

The tag will be set as the transaction tag of all statements during the transaction, and as + * the transaction tag of the commit. + * + *

The transaction tag will automatically be cleared after the transaction has ended. + * + * @param tag The tag to use. + */ + default void setTransactionTag(String tag) throws SQLException { + throw new UnsupportedOperationException(); + }; + + /** @return The transaction tag of the current transaction. */ + default String getTransactionTag() throws SQLException { + throw new UnsupportedOperationException(); + }; + + /** + * Sets the statement tag to use for the next statement that will be executed. The tag is + * automatically cleared after the statement is executed. Statement tags can be used both with + * autocommit=true and autocommit=false, and can be used for partitioned DML. + * + * @param tag The statement tag to use with the next statement that will be executed on this + * connection. + */ + default void setStatementTag(String tag) throws SQLException { + throw new UnsupportedOperationException(); + }; + + /** + * @return The statement tag that will be used with the next statement that is executed on this + * connection. + */ + default String getStatementTag() throws SQLException { + throw new UnsupportedOperationException(); + }; + /** * Sets the transaction mode to use for current transaction. This method may only be called when * in a transaction, and before the transaction is actually started, i.e. before any statements diff --git a/src/main/java/com/google/cloud/spanner/jdbc/JdbcConnection.java b/src/main/java/com/google/cloud/spanner/jdbc/JdbcConnection.java index bf9120f53..53c1dc096 100644 --- a/src/main/java/com/google/cloud/spanner/jdbc/JdbcConnection.java +++ b/src/main/java/com/google/cloud/spanner/jdbc/JdbcConnection.java @@ -78,6 +78,38 @@ public String nativeSQL(String sql) throws SQLException { .sqlWithNamedParameters; } + @Override + public String getStatementTag() throws SQLException { + checkClosed(); + return getSpannerConnection().getStatementTag(); + } + + @Override + public void setStatementTag(String tag) throws SQLException { + checkClosed(); + try { + getSpannerConnection().setStatementTag(tag); + } catch (SpannerException e) { + throw JdbcSqlExceptionFactory.of(e); + } + } + + @Override + public String getTransactionTag() throws SQLException { + checkClosed(); + return getSpannerConnection().getTransactionTag(); + } + + @Override + public void setTransactionTag(String tag) throws SQLException { + checkClosed(); + try { + getSpannerConnection().setTransactionTag(tag); + } catch (SpannerException e) { + throw JdbcSqlExceptionFactory.of(e); + } + } + @Override public void setTransactionMode(TransactionMode mode) throws SQLException { checkClosed(); diff --git a/synth.metadata b/synth.metadata index 1e125704d..50c74895a 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,14 +4,14 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-spanner-jdbc.git", - "sha": "72d109fdea7e17cda53cffbe640dc51adf4fdf1a" + "sha": "7a6953004fd1401a98f95ea3b351662eb8ab81d7" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "87254ac89a9559864c0a245d6b150406439ce3d8" + "sha": "5d3c52f5db664eee9026db76b5bcb466f3a09ca9" } } ], diff --git a/versions.txt b/versions.txt index 5d7374ae0..4fc1d7c3d 100644 --- a/versions.txt +++ b/versions.txt @@ -1,4 +1,4 @@ # Format: # module:released-version:current-version -google-cloud-spanner-jdbc:2.2.6:2.2.6 +google-cloud-spanner-jdbc:2.3.0:2.3.0