I faced such problem. When I make a lot of API requests, then the base stops responding and gives an JDBCConnectionException “Unable to acquire JDBC Connection” error. I tried to increase the number of POOL Connections, but it doesn't help. Could you describe how JPA works when requested? Do I understand correctly that if, for example, MAX-POOL = 2, then the user, having accessed from one thread by calling ONE, receives OneConnection, then when he accesses the TWO repository, he receives a SecondConnection? That is, when accessing TWO repositories from one thread, the user takes TWO CONNECTIONS? Or how? If so, how can we fix this so that there is only one connection per user from one thread?
class Controller {
@Resource
RepositoryOne one;
@Resource
RepositoryTwo two;
/*
This is a sample code!
There may be syntax errors.
I wrote in a notebook.
The main question is how does returning
two results from different repositories work?
*/
String getResult() {
// If I call this method VERY MANY TIMES!
// For example ApacheBenchmark.
// Then the method raises an error:
// --------------------------------
// JDBCConnectionException “Unable to acquire JDBC Connection”
// --------------------------------
return one.query() + two.query()
}
@Repository
interface RepositoryOne extends JPA {
@Query("SELECT `title` from `anything` where `something` = 0")
String query();
}
@Repository
interface RepositoryTwo extends JPA {
@Query("SELECT `title` from `anything` where `something` = 0")
String query();
}
}