Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring JPA Hikari multiple connection pool with same datasource

I'm using Spring JPA for connecting to the data source. My requirement is to have multiple connection pools to the same data source so that I can manage the DB operations based on priority

Is there a way to have multiple connection pools with the same data source?

I was going through this example and I want to do almost the same thing but with the same datasource using Spring JPA

like image 482
Thiru Avatar asked Oct 16 '25 04:10

Thiru


1 Answers

Yes, you can create even the same DataSource just with different pool name.

For example method the will create DataSource with different pool name:

private javax.sql.DataSource dataSource(String poolName) {
    final HikariDataSource dataSource = new HikariDataSource();
    //...setup DataSource properties
    dataSource.setPoolName(poolName);
}
like image 173
user7294900 Avatar answered Oct 17 '25 19:10

user7294900



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!