title: Can't close db connection with MyBatis
body: <p><strong>What I'm doing</strong>:</p>
  
  <p>I've got an AWS Lambda, written in Kotlin (JVM) which reads a message from a queue and writes something on a MySQL table.</p>
  
  <p>I'm using MyBatis for this purpose, and this is a short simplified snippet of what I'm doing inside the Handler:</p>
  
  <pre><code>// initializing configuration
  val dataSource = PooledDataSource(driver, url, username, password)
  val environment = Environment(environmentName, JdbcTransactionFactory(), dataSource)
  val configuration = Configuration(environment)
  
  try {
      val builder = SqlSessionFactoryBuilder()
      val session = builder.build(configuration).openSession()
      val mapper: CustomMapper = session.getMapper(CustomMapper::class.java)
      mapper.doSomething()
      session.commit()
  } finally {
      session.close()
  }
  </code></pre>
  
  <p><strong>My problem</strong>:</p>
  
  <p>When this Lambda is executed, some connections remain opened on the database. They get destroyed only when the lambda container is automatically destroyed.</p>
  
  <p>Why is this happening since I'm closing all the sessions? Is there anything that I can do in order to prevent this behaviour?</p>