https://kotlinlang.org logo
Join SlackCommunities
Powered by
# jdbi
  • a

    asad.awadia

    12/07/2020, 7:12 PM
    Made this channel to discuss the JDBI library https://jdbi.org/
  • a

    asad.awadia

    12/20/2020, 9:21 PM
    @Muneeb Ali 👋 hey! I didn’t know ios used jdbi 😛
    m
    • 2
    • 3
  • c

    Cameron Stuart

    07/05/2021, 8:53 AM
    Hi! Can anyone point me toward docs / examples for Kotlin JDBI in micronaut? I can't seem to get started with (by possibly injecting?) the JDBI handle from my hikari/jdbc connected database to get a basic query running. I feel like once I know how I can access the handle, the rest should pretty easy
  • a

    asad.awadia

    08/12/2021, 2:36 PM
    wdym in micronaut?
  • a

    asad.awadia

    08/12/2021, 2:36 PM
    @Cameron Stuart https://github.com/tipsy/javalinstagram/tree/master/src/main/kotlin/javalinstagram here is an example of using jdbi with kotlin
  • a

    asad.awadia

    08/12/2021, 2:37 PM
    https://gitlab.com/asad-awadia/kotlin-server-app/-/blob/master/src/main/kotlin/org/example/Hello.kt#L23 this is from my repo
  • a

    asad.awadia

    08/14/2021, 3:13 AM
    Copy code
    val props = Properties()
    props.setProperty("dataSourceClassName", "com.impossibl.postgres.jdbc.PGDataSource") // <https://github.com/impossibl/pgjdbc-ng>
    props.setProperty("dataSource.user", "postgres")
    props.setProperty("dataSource.password", "password")
    props.setProperty("dataSource.databaseName", "postgres")
    
    val config = HikariConfig(props)
    config.jdbcUrl = "jdbc:<postgresql://localhost:5432/postgres>"
    
    val ds = HikariDataSource(config)
    val connectionPooledJdbi = Jdbi.create(ds)
    
    connectionPooledJdbi.useHandle<Exception> {
       println(it.createQuery("SELECT * from users").mapToMap().first())
    }
    🙌 1
  • c

    Cameron Stuart

    08/14/2021, 6:22 AM
    Thanks @asad.awadia!