© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2023
A. LilleaasPro Kotlin Web Apps from Scratchhttps://doi.org/10.1007/978-1-4842-9057-6_5

5. Connecting to and Migrating SQL Databases

August Lilleaas1  
(1)
Oslo, Norway
 

Your web app needs somewhere to store and read data. By far the most common place to do that is in a SQL database. This chapter goes through all the wiring you need to connect to your database with a connection pool, how to set up the initial schema, and how to maintain changes to your database schema over time, as requirements inevitably change.

If you’re new to Kotlin, here are some language features that you’ll see examples of in this chapter:
  • Closing and cleaning up resources with use

  • AutoCloseable ...

Get Pro Kotlin Web Apps from Scratch: Building Production-Ready Web Apps Without a Framework now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.