Spring is losing connection to the DB and does not recover or reconnect

后端 未结 4 1256
予麋鹿
予麋鹿 2020-12-13 10:15

I have a spring-boot application on the same host as the Maria DB and both are running fine for some time. But between 12 hours and 2 days it seems that the spring boot appl

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-13 10:59

    Per a senior member in the Spring forums, the Spring DataSource is not intended for production use:

    The above answers are only part of the solution. Indeed you need proper transaction managent AND you need a connection pool. The DriverManagerDataSource is NOT meant for production, it opens and closes a datebase connection each time it needs one.

    Instead you can use C3P0 as your DataSource which handles the reconnect and is much better in performance. Here's a quick example of a potential configuration in a Spring xml configuration:

    
        
        
        
        
        
        
        
        
    
    
        
    
    

提交回复
热议问题