Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Try set initial pool size of database connections (spring-boot)

So, i have a application that uses spring-boot 1.4.0 and a Oracle database. I'm trying to define the number of connections of the pool in the application.properties, using these configs:

spring.datasource.driverClassName = oracle.jdbc.OracleDriver
spring.datasource.url = url
spring.datasource.username = username
spring.datasource.password = password
spring.datasource.maxActive= x
spring.datasource.initialSize= y
spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1 from dual

And i'm using the query

select *from V$SESSION where username= 'username';

to check the database connections, but when i run the application it's always using 10 connections, despite what i define as the initialSize. I tried to check other stackoverflow answers and examples on GitHub and i don't know why it's not working, so i would appreciate if someone can help me. Thanks!

like image 798
Arthur Monteforte Avatar asked Nov 03 '16 12:11

Arthur Monteforte


People also ask

What is the default connection pool size in spring boot?

You can still configure it by increasing the max connections (the default is 10 for instance).


1 Answers

Spring Boot 1.4 does not bind the DataSource in the spring.datasource namespace anymore. Each supported connection pool implementations have a dedicated namespace for their respective keys. You are probably looking at older samples.

You first need to identify which connection pool you are using (if you're relying on the starter you should probably get the Tomcat JDBC pool, see spring.datasource.tomcat). Use your IDE to get the list of keys you can use.

like image 53
Stephane Nicoll Avatar answered Oct 15 '22 00:10

Stephane Nicoll