Repository: googleapis/java-spanner-jdbc
Pull request #1379 (2023-10-02 19:31:33)

chore(deps): update dependency com.google.cloud:libraries-bom to v26.24.0
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [com.google.cloud:libraries-bom](https://cloud.google.com/java/docs/bom) ([source](https://togithub.com/googleapis/java-cloud-bom)) | `26.23.0` -> `26.24.0` | [![age](https://developer.mend.io/api/mc/badges/age/maven/com.google.cloud:libraries-bom/26.24.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/com.google.cloud:libraries-bom/26.24.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/com.google.cloud:libraries-bom/26.23.0/26.24.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/com.google.cloud:libraries-bom/26.23.0/26.24.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>googleapis/java-cloud-bom (com.google.cloud:libraries-bom)</summary>

### [`v26.24.0`](https://togithub.com/googleapis/java-cloud-bom/blob/HEAD/CHANGELOG.md#26240-2023-10-02)

[Compare Source](https://togithub.com/googleapis/java-cloud-bom/compare/v26.23.0...v26.24.0)

##### Dependencies

-   update actions/checkout action to v4 ([#&#8203;6184](https://togithub.com/googleapis/java-cloud-bom/issues/6184)) ([63c5bae](https://togithub.com/googleapis/java-cloud-bom/commit/63c5bae32d4c323603930180f749995c14aff59e))
-   update dependency com.google.cloud:first-party-dependencies to v3.16.1 ([#&#8203;6195](https://togithub.com/googleapis/java-cloud-bom/issues/6195)) ([e87a47c](https://togithub.com/googleapis/java-cloud-bom/commit/e87a47c412e4c20a8a701f7d778971a56cbd210a))
-   update dependency com.google.cloud:gapic-libraries-bom to v1.21.0 ([#&#8203;6215](https://togithub.com/googleapis/java-cloud-bom/issues/6215)) ([da14d27](https://togithub.com/googleapis/java-cloud-bom/commit/da14d272b0e4d747643b8906d9a35527e401ba1b))
-   update dependency com.google.cloud:google-cloud-bigquery to v2.33.1 ([#&#8203;6202](https://togithub.com/googleapis/java-cloud-bom/issues/6202)) ([9104524](https://togithub.com/googleapis/java-cloud-bom/commit/9104524f52bcbe2682dd0cd3b903c87124a41934))
-   update dependency com.google.cloud:google-cloud-bigquerystorage-bom to v2.43.0 ([#&#8203;6216](https://togithub.com/googleapis/java-cloud-bom/issues/6216)) ([9fcfdd1](https://togithub.com/googleapis/java-cloud-bom/commit/9fcfdd18f53b1be0377feb48e07696d4e26be2d0))
-   update dependency com.google.cloud:google-cloud-bigtable-bom to v2.27.3 ([#&#8203;6203](https://togithub.com/googleapis/java-cloud-bom/issues/6203)) ([98f977c](https://togithub.com/googleapis/java-cloud-bom/commit/98f977c2bda5063ac531334c199d549bfb162168))
-   update dependency com.google.cloud:google-cloud-bigtable-bom to v2.27.4 ([#&#8203;6212](https://togithub.com/googleapis/java-cloud-bom/issues/6212)) ([532bbf6](https://togithub.com/googleapis/java-cloud-bom/commit/532bbf6b52a2a7d4406e78d30da71bd582508987))
-   update dependency com.google.cloud:google-cloud-datastore-bom to v2.17.2 ([#&#8203;6200](https://togithub.com/googleapis/java-cloud-bom/issues/6200)) ([9d9328b](https://togithub.com/googleapis/java-cloud-bom/commit/9d9328b5b7351e6e32f239bf90e29d52f2afb3e2))
-   update dependency com.google.cloud:google-cloud-firestore-bom to v3.14.4 ([#&#8203;6204](https://togithub.com/googleapis/java-cloud-bom/issues/6204)) ([557111a](https://togithub.com/googleapis/java-cloud-bom/commit/557111a5e893f42619cd0708d4a278301f57f7d1))
-   update dependency com.google.cloud:google-cloud-logging-bom to v3.15.10 ([#&#8203;6213](https://togithub.com/googleapis/java-cloud-bom/issues/6213)) ([433b87b](https://togithub.com/googleapis/java-cloud-bom/commit/433b87bdfc7587af80927f645ede5ef367e947aa))
-   update dependency com.google.cloud:google-cloud-logging-logback to v0.130.23-alpha ([#&#8203;6214](https://togithub.com/googleapis/java-cloud-bom/issues/6214)) ([04aedab](https://togithub.com/googleapis/java-cloud-bom/commit/04aedab54e84fa6f13c9175672dc7f5ab6c1ecb6))
-   update dependency com.google.cloud:google-cloud-nio to v0.127.4 ([#&#8203;6199](https://togithub.com/googleapis/java-cloud-bom/issues/6199)) ([943d623](https://togithub.com/googleapis/java-cloud-bom/commit/943d623dd705997eac20d7eece882cd3a776b411))
-   update dependency com.google.cloud:google-cloud-pubsub-bom to v1.125.2 ([#&#8203;6187](https://togithub.com/googleapis/java-cloud-bom/issues/6187)) ([3c630a5](https://togithub.com/googleapis/java-cloud-bom/commit/3c630a55cbeab73e3458c38e16d6f8038a6b41dd))
-   update dependency com.google.cloud:google-cloud-pubsub-bom to v1.125.5 ([#&#8203;6201](https://togithub.com/googleapis/java-cloud-bom/issues/6201)) ([c2d6ee6](https://togithub.com/googleapis/java-cloud-bom/commit/c2d6ee600f61aaf9b2a8a36c447b91c75e0c2aca))
-   update dependency com.google.cloud:google-cloud-pubsublite-bom to v1.12.15 ([#&#8203;6218](https://togithub.com/googleapis/java-cloud-bom/issues/6218)) ([2acd60c](https://togithub.com/googleapis/java-cloud-bom/commit/2acd60c8402f7265b3723999daba81c43603db7d))
-   update dependency com.google.cloud:google-cloud-spanner-bom to v6.48.0 ([#&#8203;6197](https://togithub.com/googleapis/java-cloud-bom/issues/6197)) ([a6964f7](https://togithub.com/googleapis/java-cloud-bom/commit/a6964f7e42ea6cc41131ca80ba2e14952070bf84))
-   update dependency com.google.cloud:google-cloud-spanner-bom to v6.49.0 ([#&#8203;6217](https://togithub.com/googleapis/java-cloud-bom/issues/6217)) ([491e3ca](https://togithub.com/googleapis/java-cloud-bom/commit/491e3cab1c99c80a7f7ae6b54911217106a1f7ba))
-   update dependency com.google.cloud:google-cloud-spanner-jdbc to v2.13.0 ([#&#8203;6188](https://togithub.com/googleapis/java-cloud-bom/issues/6188)) ([9105347](https://togithub.com/googleapis/java-cloud-bom/commit/910534772aab3562a2264b94893c1f9231b7a7b7))
-   update dependency com.google.cloud:google-cloud-spanner-jdbc to v2.13.4 ([#&#8203;6194](https://togithub.com/googleapis/java-cloud-bom/issues/6194)) ([6a177d7](https://togithub.com/googleapis/java-cloud-bom/commit/6a177d7bcd9fb2796d2295e827ef09d4c13979e3))
-   update dependency com.google.cloud:google-cloud-storage-bom to v2.27.1 ([#&#8203;6198](https://togithub.com/googleapis/java-cloud-bom/issues/6198)) ([f64ac7a](https://togithub.com/googleapis/java-cloud-bom/commit/f64ac7a2fecc634931e8dec70df21486cfb57dff))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/googleapis/java-spanner-jdbc).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjMiLCJ1cGRhdGVkSW5WZXIiOiIzNy44LjEiLCJ0YXJnZXRCcmFuY2giOiJtYWluIn0=-->



Patch:
diff --git a/pom.xml b/pom.xml
index ee537da..66f8a9a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -420,7 +420,6 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-javadoc-plugin</artifactId>
-        <version>3.6.0</version>
         <reportSets>
           <reportSet>
             <id>html</id>
diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml
index 015e8b3..1bc1db9 100644
--- a/samples/install-without-bom/pom.xml
+++ b/samples/install-without-bom/pom.xml
@@ -29,7 +29,7 @@
     <dependency>
       <groupId>com.google.cloud</groupId>
       <artifactId>google-cloud-spanner-jdbc</artifactId>
-      <version>2.13.2</version>
+      <version>2.13.4</version>
     </dependency>
     <!-- [END spanner-jdbc_install_without_bom] -->
 
diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml
index a00b7a5..3144149 100644
--- a/samples/snippets/pom.xml
+++ b/samples/snippets/pom.xml
@@ -30,7 +30,7 @@
       <dependency>
         <groupId>com.google.cloud</groupId>
         <artifactId>libraries-bom</artifactId>
-        <version>26.23.0</version>
+        <version>26.24.0</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
diff --git a/samples/spring-data-jdbc/pom.xml b/samples/spring-data-jdbc/pom.xml
index 20f858d..5ed1d02 100644
--- a/samples/spring-data-jdbc/pom.xml
+++ b/samples/spring-data-jdbc/pom.xml
@@ -30,7 +30,7 @@
       <dependency>
         <groupId>com.google.cloud</groupId>
         <artifactId>libraries-bom</artifactId>
-        <version>26.23.0</version>
+        <version>26.24.0</version>
         <scope>import</scope>
         <type>pom</type>
       </dependency>
diff --git a/samples/spring-data-mybatis/pom.xml b/samples/spring-data-mybatis/pom.xml
index 07563c6..8dbf025 100644
--- a/samples/spring-data-mybatis/pom.xml
+++ b/samples/spring-data-mybatis/pom.xml
@@ -35,7 +35,7 @@
       <dependency>
         <groupId>com.google.cloud</groupId>
         <artifactId>libraries-bom</artifactId>
-        <version>26.23.0</version>
+        <version>26.24.0</version>
         <scope>import</scope>
         <type>pom</type>
       </dependency>
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 6031afe..9248dac 100644
--- a/src/main/java/com/google/cloud/spanner/jdbc/JdbcConnection.java
+++ b/src/main/java/com/google/cloud/spanner/jdbc/JdbcConnection.java
@@ -47,6 +47,7 @@ import java.util.Iterator;
 import java.util.Map;
 import java.util.function.BiConsumer;
 import java.util.function.Function;
+import javax.annotation.Nonnull;
 
 /** Jdbc Connection class for Google Cloud Spanner */
 class JdbcConnection extends AbstractJdbcConnection {
@@ -394,31 +395,66 @@ class JdbcConnection extends AbstractJdbcConnection {
   @Override
   public void setCatalog(String catalog) throws SQLException {
     // This method could be changed to allow the user to change to another database.
-    // For now we only support setting an empty string in order to support frameworks
+    // For now, we only support setting the default catalog in order to support frameworks
     // and applications that set this when no catalog has been specified in the connection
     // URL.
     checkClosed();
-    JdbcPreconditions.checkArgument("".equals(catalog), "Only catalog \"\" is supported");
+    checkValidCatalog(catalog);
+  }
+
+  void checkValidCatalog(String catalog) throws SQLException {
+    String defaultCatalog = getDefaultCatalog();
+    JdbcPreconditions.checkArgument(
+        defaultCatalog.equals(catalog),
+        String.format("Only catalog %s is supported", defaultCatalog));
   }
 
   @Override
   public String getCatalog() throws SQLException {
     checkClosed();
-    return "";
+    return getDefaultCatalog();
+  }
+
+  @Nonnull
+  String getDefaultCatalog() {
+    switch (getDialect()) {
+      case POSTGRESQL:
+        String database = getConnectionOptions().getDatabaseName();
+        // It should not be possible that database is null, but it's better to be safe than sorry.
+        return database == null ? "" : database;
+      case GOOGLE_STANDARD_SQL:
+      default:
+        return "";
+    }
   }
 
   @Override
   public void setSchema(String schema) throws SQLException {
     checkClosed();
-    // Cloud Spanner does not support schemas, but does contain a pseudo 'empty string' schema that
-    // might be set by frameworks and applications that read the database metadata.
-    JdbcPreconditions.checkArgument("".equals(schema), "Only schema \"\" is supported");
+    checkValidSchema(schema);
+  }
+
+  void checkValidSchema(String schema) throws SQLException {
+    String defaultSchema = getDefaultSchema();
+    JdbcPreconditions.checkArgument(
+        defaultSchema.equals(schema), String.format("Only schema %s is supported", defaultSchema));
   }
 
   @Override
   public String getSchema() throws SQLException {
     checkClosed();
-    return "";
+    return getDefaultSchema();
+  }
+
+  @Nonnull
+  String getDefaultSchema() {
+    switch (getDialect()) {
+      case POSTGRESQL:
+        return "public";
+      case GOOGLE_STANDARD_SQL:
+      default:
+        return "";
+    }
   }
 
   @Override
diff --git a/src/main/java/com/google/cloud/spanner/jdbc/JdbcDatabaseMetaData.java b/src/main/java/com/google/cloud/spanner/jdbc/JdbcDatabaseMetaData.java
index b9c7cb8..4463395 100644
--- a/src/main/java/com/google/cloud/spanner/jdbc/JdbcDatabaseMetaData.java
+++ b/src/main/java/com/google/cloud/spanner/jdbc/JdbcDatabaseMetaData.java
@@ -777,11 +777,12 @@ class JdbcDatabaseMetaData extends AbstractJdbcWrapper implements DatabaseMetaDa
   }
 
   @Override
-  public ResultSet getCatalogs() {
+  public ResultSet getCatalogs() throws SQLException {
     return JdbcResultSet.of(
         ResultSets.forRows(
             Type.struct(StructField.of("TABLE_CAT", Type.string())),
-            Collections.singletonList(Struct.newBuilder().set("TABLE_CAT").to("").build())));
+            Collections.singletonList(
+                Struct.newBuilder().set("TABLE_CAT").to(getConnection().getCatalog()).build())));
   }
 
   @Override
@@ -1524,9 +1525,10 @@ class JdbcDatabaseMetaData extends AbstractJdbcWrapper implements DatabaseMetaDa
   @Override
   public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException {
     String sql = readSqlFromFile("DatabaseMetaData_GetSchemas.sql", connection.getDialect());
-    JdbcPreparedStatement statement =
-        prepareStatementReplaceNullWithAnyString(sql, catalog, schemaPattern);
-    return statement.executeQueryWithOptions(InternalMetadataQuery.INSTANCE);
+    try (JdbcPreparedStatement statement =
+        prepareStatementReplaceNullWithAnyString(sql, catalog, schemaPattern)) {
+      return statement.executeQueryWithOptions(InternalMetadataQuery.INSTANCE);
+    }
   }
 
   @Override


Test patch:
diff --git a/src/test/java/com/google/cloud/spanner/jdbc/JdbcConnectionTest.java b/src/test/java/com/google/cloud/spanner/jdbc/JdbcConnectionTest.java
index 592d404..ff811f3 100644
--- a/src/test/java/com/google/cloud/spanner/jdbc/JdbcConnectionTest.java
+++ b/src/test/java/com/google/cloud/spanner/jdbc/JdbcConnectionTest.java
@@ -20,6 +20,7 @@ import static com.google.common.truth.Truth.assertThat;
 import static com.google.common.truth.Truth.assertWithMessage;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.mockito.Mockito.any;
@@ -700,34 +701,33 @@ public class JdbcConnectionTest {
     ConnectionOptions options = mockOptions();
     when(options.getDatabaseName()).thenReturn("test");
     try (JdbcConnection connection = createConnection(options)) {
-      // The connection should always return the empty string as the current catalog, as no other
+      // The connection should always return the default catalog as the current catalog, as no other
       // catalogs exist in the INFORMATION_SCHEMA.
-      assertThat(connection.getCatalog()).isEqualTo("");
+      // The default catalog is the empty string for GoogleSQL databases.
+      // The default catalog is the database name for PostgreSQL databases.
+      assertEquals(connection.getDefaultCatalog(), connection.getCatalog());
       // This should be allowed.
-      connection.setCatalog("");
-      try {
-        // This should cause an exception.
-        connection.setCatalog("other");
-        fail("missing expected exception");
-      } catch (JdbcSqlExceptionImpl e) {
-        assertThat(e.getCode()).isEqualTo(Code.INVALID_ARGUMENT);
-      }
+      connection.setCatalog(connection.getDefaultCatalog());
+      // This should cause an exception.
+      JdbcSqlExceptionImpl exception =
+          assertThrows(JdbcSqlExceptionImpl.class, () -> connection.setCatalog("other"));
+      assertEquals(Code.INVALID_ARGUMENT, exception.getCode());
     }
   }
 
   @Test
   public void testSchema() throws SQLException {
     try (JdbcConnection connection = createConnection(mockOptions())) {
-      assertThat(connection.getSchema()).isEqualTo("");
+      // The connection should always return the default schema as the current schema, as we
+      // currently do not support setting the connection to a different schema.
+      // The default schema is the empty string for GoogleSQL databases.
+      // The default schema is 'public' for PostgreSQL databases.
+      assertEquals(connection.getDefaultSchema(), connection.getSchema());
       // This should be allowed.
-      connection.setSchema("");
-      try {
-        // This should cause an exception.
-        connection.setSchema("other");
-        fail("missing expected exception");
-      } catch (JdbcSqlExceptionImpl e) {
-        assertThat(e.getCode()).isEqualTo(Code.INVALID_ARGUMENT);
-      }
+      connection.setSchema(connection.getDefaultSchema());
+      JdbcSqlExceptionImpl exception =
+          assertThrows(JdbcSqlExceptionImpl.class, () -> connection.setSchema("other"));
+      assertEquals(Code.INVALID_ARGUMENT, exception.getCode());
     }
   }
 
diff --git a/src/test/java/com/google/cloud/spanner/jdbc/JdbcDatabaseMetaDataTest.java b/src/test/java/com/google/cloud/spanner/jdbc/JdbcDatabaseMetaDataTest.java
index 6a2b0ca..9782e96 100644
--- a/src/test/java/com/google/cloud/spanner/jdbc/JdbcDatabaseMetaDataTest.java
+++ b/src/test/java/com/google/cloud/spanner/jdbc/JdbcDatabaseMetaDataTest.java
@@ -41,10 +41,19 @@ import java.sql.Types;
 import java.util.Objects;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
 
-@RunWith(JUnit4.class)
+@RunWith(Parameterized.class)
 public class JdbcDatabaseMetaDataTest {
+  @Parameter public Dialect dialect;
+
+  @Parameters(name = "dialect = {0}")
+  public static Object[] data() {
+    return Dialect.values();
+  }
+
   private static final String DEFAULT_CATALOG = "";
   private static final String DEFAULT_SCHEMA = "";
   private static final String TEST_TABLE = "FOO";
@@ -314,10 +323,12 @@ public class JdbcDatabaseMetaDataTest {
   @Test
   public void testGetCatalogs() throws SQLException {
     JdbcConnection connection = mock(JdbcConnection.class);
+    when(connection.getDialect()).thenReturn(dialect);
+    when(connection.getCatalog()).thenCallRealMethod();
     DatabaseMetaData meta = new JdbcDatabaseMetaData(connection);
     try (ResultSet rs = meta.getCatalogs()) {
       assertThat(rs.next(), is(true));
-      assertThat(rs.getString("TABLE_CAT"), is(equalTo("")));
+      assertThat(rs.getString("TABLE_CAT"), is(equalTo(connection.getDefaultCatalog())));
       assertThat(rs.next(), is(false));
       ResultSetMetaData rsmd = rs.getMetaData();
       assertThat(rsmd.getColumnCount(), is(equalTo(1)));
diff --git a/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcDatabaseMetaDataTest.java b/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcDatabaseMetaDataTest.java
index 7e2481a..820bdfa 100644
--- a/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcDatabaseMetaDataTest.java
+++ b/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcDatabaseMetaDataTest.java
@@ -822,6 +822,7 @@ public class ITJdbcDatabaseMetaDataTest extends ITAbstractJdbcTest {
   @Test
   public void testGetSchemas() throws SQLException {
     try (Connection connection = createConnection(env, database)) {
+      assertEquals("", connection.getSchema());
       try (ResultSet rs = connection.getMetaData().getSchemas()) {
         assertThat(rs.next(), is(true));
         assertThat(rs.getString("TABLE_SCHEM"), is(equalTo(DEFAULT_SCHEMA)));
@@ -829,11 +830,22 @@ public class ITJdbcDatabaseMetaDataTest extends ITAbstractJdbcTest {
         assertThat(rs.next(), is(true));
         assertThat(rs.getString("TABLE_SCHEM"), is(equalTo("INFORMATION_SCHEMA")));
         assertThat(rs.getString("TABLE_CATALOG"), is(equalTo(DEFAULT_CATALOG)));
-        if (!EmulatorSpannerHelper.isUsingEmulator()) {
-          assertThat(rs.next(), is(true));
-          assertThat(rs.getString("TABLE_SCHEM"), is(equalTo("SPANNER_SYS")));
-          assertThat(rs.getString("TABLE_CATALOG"), is(equalTo(DEFAULT_CATALOG)));
-        }
+        assertThat(rs.next(), is(true));
+        assertThat(rs.getString("TABLE_SCHEM"), is(equalTo("SPANNER_SYS")));
+        assertThat(rs.getString("TABLE_CATALOG"), is(equalTo(DEFAULT_CATALOG)));
+        assertFalse(rs.next());
+      }
+    }
+  }
+
+  @Test
+  public void testGetCatalogs() throws SQLException {
+    try (Connection connection = createConnection(env, database)) {
+      assertEquals("", connection.getCatalog());
+      try (ResultSet rs = connection.getMetaData().getCatalogs()) {
+        assertTrue(rs.next());
+        assertEquals("", rs.getString("TABLE_CAT"));
+
         assertFalse(rs.next());
       }
     }
diff --git a/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcPgDatabaseMetaDataTest.java b/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcPgDatabaseMetaDataTest.java
index ff0bff7..56d75db 100644
--- a/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcPgDatabaseMetaDataTest.java
+++ b/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcPgDatabaseMetaDataTest.java
@@ -752,6 +752,7 @@ public class ITJdbcPgDatabaseMetaDataTest extends ITAbstractJdbcTest {
   @Test
   public void testGetSchemas() throws SQLException {
     try (Connection connection = createConnection(env, database)) {
+      assertEquals("public", connection.getSchema());
       try (ResultSet rs = connection.getMetaData().getSchemas()) {
         assertTrue(rs.next());
         assertEquals(getDefaultCatalog(database), rs.getString("TABLE_CATALOG"));
@@ -774,6 +775,19 @@ public class ITJdbcPgDatabaseMetaDataTest extends ITAbstractJdbcTest {
     }
   }
 
+  @Test
+  public void testGetCatalogs() throws SQLException {
+    try (Connection connection = createConnection(env, database)) {
+      assertEquals(database.getId().getDatabase(), connection.getCatalog());
+      try (ResultSet rs = connection.getMetaData().getCatalogs()) {
+        assertTrue(rs.next());
+        assertEquals(database.getId().getDatabase(), rs.getString("TABLE_CAT"));
+
+        assertFalse(rs.next());
+      }
+    }
+  }
+
   private static final class Table {
     private final String name;
     private final String type;