M
M
mitaichik2017-01-17 14:01:20
MySQL
mitaichik, 2017-01-17 14:01:20

How to setup MySQL connection pool?

Hello! Newbie in java.
I'm trying to work in Spring with a MySQL database.
I made a DataSource based on the com.mysql.cj.jdbc.Driver driver + JdbcTemplate bean, and launched an application in which 60 threads periodically write to the database.
MySQL server shows floating number of connections. Such feeling that such sheaf creates connection on each request. Is it so? For some reason, I thought that one connection would be created through which all requests would pass.
Googling, I realized that I need to do a pool of connections, but Spring doesn’t know how to do this out of the box. Is it so? If so, which library should I choose for pooling? I have Spring in its purest form (not Spring Boot, works without a container / application server, just like an application launched from the console, and this is not a web application)
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
al_gon, 2017-01-17
@mitaichik

Yes, the spring itself does not.
docs.spring.io/spring/docs/current/javadoc-api/org...
stackoverflow.com/questions/5117191/spring-jdbc-co...
stackoverflow.com/questions/520585/connection-pool...
Pay attention to c3p0 and HikariCP
https://www.javacodegeeks.com/2014/05/adding-c3po-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question