I have a question about the DriverManagerDataSource in Spring.
Our microservice uses Spring Boot and Hibernate to connect to Druid Database. We use DriverManagerDataSource to create our dataSource instance. From the documentation of DriverManagerDataSource, we know that it does not have a proper connection pool implementation.
However, when we tested the microservice, we can see 10 established TCP connections when we increased the query load to 10 concurrent virtual users, and those 10 connections remained established even after the queries completed. They only reduced to 1 connection after we initiated a new query with only 1 concurrent virtual user.
The above symptom indicates that there is indeed a connection pool established. I am pretty confused at this point: where is this pool coming from?
I tried the test mentioned here, but I got
Datasource = org.springframework.jdbc.datasource.DriverManagerDataSource@xxxx;
(pls ignore the xxxx). The following is a partial pint out of the microservice's startup that shows Tomcat started:
[30m2024-03-12 10:03:27,567[0;39m [34mINFO [0;39m [[34mmain[0;39m] [33morg.apache.juli.logging.DirectJDKLog[0;39m [,] - Starting service [Tomcat]`
[30m2024-03-12 10:03:27,568[0;39m [34mINFO [0;39m [[34mmain[0;39m] [33morg.apache.juli.logging.DirectJDKLog[0;39m [,] - Starting Servlet engine: [Apache Tomcat/9.0.86];
I am not sure if Tomcat JDBC's connection pool automatically kicked in?
org.springframework.jdbc.datasource.DriverManagerDataSourceis not a connection pool. It is a simple implementation ofjavax.sql.DataSourcewhich was autowired to the spring boot application.If you use Hibernate, you should read