title: Initialise MySQL Testcontainer using R2DBC and Jooq
body: <p>I want to write integration test for my microservice currently using Kotlin, Jooq and R2dbc at repository level.
  I want my test to work in R2dbc mode as well, but for some reason getting this exception:</p>
  <pre><code>Caused by: org.testcontainers.containers.JdbcDatabaseContainer$NoDriverFoundException: Could not get Driver
      at org.testcontainers.containers.JdbcDatabaseContainer.getJdbcDriverInstance(JdbcDatabaseContainer.java:187)
      at org.testcontainers.containers.JdbcDatabaseContainer.createConnection(JdbcDatabaseContainer.java:209)
      at org.testcontainers.containers.JdbcDatabaseContainer.waitUntilContainerStarted(JdbcDatabaseContainer.java:147)
      at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:466)
      ... 10 common frames omitted
  Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
  </code></pre>
  <p>Probably, I have to point somewhere that I want to use r2dbc only, not jdbc? I've seen the <a href="https://www.testcontainers.org/modules/databases/r2dbc/" rel="nofollow noreferrer">specs</a> but not sure whether I applied <code>TC_INITSCRIPT</code> and <code>TC_IMAGE_TAG</code> correctly.
  I don't use Spring Data r2dbc (jooq only), that's why <code>ResourceDatabasePopulator</code> is not an option for me.</p>
  <p>My test looks like:</p>
  <pre><code>@SpringBootTest(classes = [UserServiceApp::class])
  @ActiveProfiles(profiles = [&quot;test&quot;])
  @AutoConfigureWebTestClient
  class UserServiceAppIT(@Autowired val client: WebTestClient) {
  
      @Nested
      inner class Find {
  
          @Test
          @DisplayName(&quot;Find existing user by id&quot;)
          fun `existing user credentials returns OK`() {
              val expectedUser = getCredentialsUser()  //this is a class with expected data
              val response = client.get()
                  .uri(&quot;/user/2&quot;)       //this is my endpoint
                  .accept(MediaType.APPLICATION_JSON)
                  .exchange()
                  .expectStatus().isOk
                  .expectBody(UserCredentialsModel::class.java)
                  .returnResult()
                  .responseBody
  
              assertThat(response)
                  .isNotNull
                  .isEqualTo(expectedUser)
          }
  }
  </code></pre>
  <p>Test config in yaml file:</p>
  <pre><code>server.port: 8080
  spring:
    application:
      name: User Service Test
    r2dbc:
      url: r2dbc:tc:mysql:///pharmacy?TC_IMAGE_TAG=8.0.26&amp;TC_INITSCRIPT=classpath/resources/init.sql
      password: root
      username: root
      pool:
        initial-size: 1
        max-size: 10
        max-idle-time: 30m
  </code></pre>
  <p>Dependencies (gradle):</p>
  <pre><code>buildscript {
      ext {
          springDependencyVersion = '1.0.11.RELEASE'
          springBootVersion = '2.5.3'
          kotlinVersion = '1.5.0'
          jooqPluginVersion = '6.0'
          springdocVersion = '1.5.10'
          r2dbcMySQLVersion = '0.8.2.RELEASE'
          r2dbcPoolVersion = '0.8.7.RELEASE'
          mockKVersion = '1.12.0'
          kotestVersion = '4.4.3'
          kotlinJsonVersion = '1.2.1'
          kotlinDateVersion = '0.2.1'
          testcontainersVersion = '1.16.0'
      }
  }
  </code></pre>