Configuring the built-in c3p0 pooling in Hibernate using Spring

前端 未结 2 1399
予麋鹿
予麋鹿 2020-12-05 06:18

I learned that to configure c3p0 pooling in hibernate, we can have write the configuration in hibernate.cfg.xml such this:



        
2条回答
  •  清歌不尽
    2020-12-05 06:45

    Here is a sample configuration (from our application) on how to configure c3p0 in the datasource:

    
            
            
            
             
    
            
            
            
            
            
    
    

    We use an external property file to configure some parameters, but they can be configured directly in Spring too.

    If you want hibernate to take care of the pooling, then you need to configure the Session properties:

    
        
        
        
            
                net.sf.hibernate.dialect.Oracle9Dialect
                
                    net.sf.hibernate.transaction.JDBCTransactionFactory
                
                
                    net.sf.hibernate.transaction.JDBCTransactionFactory
                
                false
                false
                0
    
                
                
                
                
                
                
          
        
    
    

    You must use one of the approaches: either pool at the datasource or pool at the hibernate Session. Never use both, as it wastes resources.

提交回复
热议问题