Thread
#exposed
    dany giguere

    dany giguere

    8 months ago
    Hello everyone. I’m in a Ktor project and I’m trying to install exposed. In which file am I supposed to put this :
    val config = HikariConfig().apply {
        jdbcUrl         = "jdbc:<mysql://localhost/dbname>"
        driverClassName = "com.mysql.cj.jdbc.Driver"
        username        = "username"
        password        = "secret"
        maximumPoolSize = 10
    }
    val dataSource = HikariDataSource(config)
    Database.connect(dataSource)
    from the documentation here: https://github.com/JetBrains/Exposed/wiki/DataBase-and-DataSource
    e

    Endre Deak

    8 months ago
    I guess you can put it anywhere as long as this code is executed when the server starts.
    dave08

    dave08

    8 months ago
    You can also put it in your DI to provide a Database instance for your repositories, especially if you have more than one database. Then you'd use
    transaction(db) {}