why is spring boot opening a lot of connections?

Viewed 975

I'm using a cloud database at elephantsql.com. As I'm using a free plan I can have only 5 concurrent connections.

I have a spring boot application that connects with this cloud database. The problem is that even when there is just one user at the website the spring boot application opens a lot of connections and some times it exceed the 5 connections.

I checked the connections at elephantsql.com and got this:

connections stats

Its seems that the following unnecessary query is increasing the amount of connections...

SET application_name = 'PostgreSQL JDBC Driver'

How could I fix this to avoid the application to open unnecessary connections?

1 Answers

The setting you're looking for is probably spring.datasource.max-active=5

Default value of this property is 10.

Related