In my project we are using JPA for querying from database. We are facing problem while running the performance and it throws exception connection unavailable.
I did check for other sources online. It is mentioned to add following properties - maxIdle, minIdle, and minEvictableIdleTimeMillis to the data source. I have set above properties along with initial-size, max-active, remove-abandoned, remove-abandoned-timeout, min-evictable-idle-time-millis etc. But it is not working.
Few resources suggest to close connection explicitly. But I am not sure how can I explicitly get the current DB connection in JPA and close it. I have included the code which I am referring.
Any suggestion on this would be very helpful. Thanks in advance.
Repository class:
public interface checkRepository extends JpaRepository<CheckEntity, Long> {
CheckEntity findById(String id);
}
Service class:
class Service{
public void method(){
try{
checkRepo.findById(id);
}catch(Exception ex){
}finally{
//Close the connection here
}
}
}