@Override
  public boolean createTable(String tableName, JDBCSchema schema) {
    // Check table ID
    checkValidTableName(tableName);

    // Check if table already exists
    if (tableIds.containsKey(tableName)) {
      throw new IllegalStateException(
          "Table " + tableName + " already exists for database " + databaseName + ".");
    }

    LOG.info("Creating table using tableName '{}'.", tableName);

    StringBuilder sql = new StringBuilder();
    try (Connection con = driver.getConnection(getUri(), username, password)) {
      Statement stmt = con.createStatement();
      sql.append("CREATE TABLE ")
          .append(tableName)
          .append(" (")
          .append(schema.toSqlStatement())
          .append(")");

      stmt.executeUpdate(sql.toString());
      stmt.close();
    } catch (Exception e) {
      throw new JDBCResourceManagerException(
          "Error creating table with SQL statement: "
              + sql
              + " (for connection with URL "
              + getUri()
              + ")",
          e);
    }

    tableIds.put(tableName, schema.getIdColumn());
    LOG.info("Successfully created table {}.{}", databaseName, tableName);

    return true;
  }
@Test
  public void testCreateTableShouldThrowErrorWhenDriverFailsToEstablishConnection()
      throws SQLException {
    when(container.getHost()).thenReturn(HOST);
    when(container.getMappedPort(JDBC_PORT)).thenReturn(MAPPED_PORT);
    doThrow(SQLException.class).when(driver).getConnection(any(), any(), any());

    assertThrows(
        JDBCResourceManagerException.class,
        () ->
            testManager.createTable(
                TABLE_NAME,
                new JDBCResourceManager.JDBCSchema(ImmutableMap.of("id", "INTEGER"), "id")));
  }