File tree Expand file tree Collapse file tree 2 files changed +16
-8
lines changed
src/main/kotlin/dev/hossain/postgresqldelight Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -33,14 +33,23 @@ class SportsRepository constructor(
33
33
SportsDatabase .Schema .create(driver)
34
34
}
35
35
36
+
37
+ /* *
38
+ * Creates a [DataSource] using [HikariDataSource].
39
+ * @param appConfig the [AppConfig] required to create the [DataSource].
40
+ */
36
41
private fun getDataSource (appConfig : AppConfig ): DataSource {
37
- val hikariConfig = HikariConfig ()
38
42
// https://jdbc.postgresql.org/documentation/use/
39
- hikariConfig.setJdbcUrl(" jdbc:postgresql://${appConfig.dbHost} /${appConfig.dbName} " )
40
- hikariConfig.driverClassName = " org.postgresql.Driver"
41
- hikariConfig.username = appConfig.dbUsername
42
- hikariConfig.password = appConfig.dbPassword
43
-
44
- return HikariDataSource (hikariConfig)
43
+ val config = HikariConfig ().apply {
44
+ jdbcUrl = " jdbc:postgresql://${appConfig.dbHost} /${appConfig.dbName} "
45
+ driverClassName = " org.postgresql.Driver"
46
+ username = appConfig.dbUsername
47
+ password = appConfig.dbPassword
48
+ maximumPoolSize = 3
49
+ isAutoCommit = false
50
+ transactionIsolation = " TRANSACTION_REPEATABLE_READ"
51
+ validate()
52
+ }
53
+ return HikariDataSource (config)
45
54
}
46
55
}
You can’t perform that action at this time.
0 commit comments