Skip to content

Commit

Permalink
[#12048] Configure connection pool using hikari (#12978)
Browse files Browse the repository at this point in the history
* Configure hikari

* Remove spacing

* Lint
  • Loading branch information
FergusMok authored Apr 3, 2024
1 parent 2ee4269 commit 38dbf29
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ dependencies {
implementation("org.jsoup:jsoup:1.15.2")
implementation("org.hibernate.orm:hibernate-core:6.1.6.Final")
implementation("org.postgresql:postgresql:42.7.2")
implementation("org.hibernate.orm:hibernate-agroal:6.1.6.Final")
implementation("io.agroal:agroal-pool:2.1")
implementation("org.hibernate:hibernate-hikaricp:6.1.6.Final")

testAnnotationProcessor(testng)

Expand Down
9 changes: 6 additions & 3 deletions src/main/java/teammates/common/util/HibernateUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,18 @@ public static void buildSessionFactory(String dbUrl, String username, String pas
Configuration config = new Configuration()
.setProperty("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect")
.setProperty("hibernate.connection.driver_class", "org.postgresql.Driver")
.setProperty("hibernate.connection.provider_class",
"org.hibernate.hikaricp.internal.HikariCPConnectionProvider")
.setProperty("hibernate.connection.username", username)
.setProperty("hibernate.connection.password", password)
.setProperty("hibernate.connection.url", dbUrl)
.setProperty("hibernate.hbm2ddl.auto", "update")
.setProperty("show_sql", "true")
.setProperty("hibernate.current_session_context_class", "thread")
.setProperty("hibernate.agroal.minSize", "5")
.setProperty("hibernate.agroal.maxSize", "50")
.setProperty("hibernate.agroal.reapTimeout", "PT1M")
.setProperty("hibernate.hikari.minimumIdle", "10")
.setProperty("hibernate.hikari.maximumPoolSize", "30")
.setProperty("hibernate.hikari.idleTimeout", "300000")
.setProperty("hibernate.hikari.connectionTimeout", "30000")
// Uncomment only during migration for optimized batch-insertion, batch-update, and batch-fetch.
// .setProperty("hibernate.jdbc.batch_size", "50")
// .setProperty("hibernate.order_updates", "true")
Expand Down

0 comments on commit 38dbf29

Please sign in to comment.