How to set up datasource with Spring for HikariCP?

后端 未结 9 883
傲寒
傲寒 2020-11-27 02:51

Hi I\'m trying to use HikariCP with Spring for connection pool. I\'m using jdbcTempLate and JdbcdaoSupport.
This is my spring configuration file for datasource:

9条回答
  •  一向
    一向 (楼主)
    2020-11-27 03:47

    you need to write this structure on your bean configuration (this is your datasource):

    
        
        
        
        
        
    
        
            
                ${dataSource.url}
                ${dataSource.username}
                ${dataSource.password}
            
        
    
    
    
    
        
    
    

    This is my example and it is working. You just need to put your properties on hibernate.properties and set it before:

    
        
            
                classpath:hibernate.properties
            
        
    
    

    Obs.: the versions are
    log4j: 1.2.16
    springframework: 3.1.4.RELEASE
    HikariCP: 1.4.0

    Properties file (hibernate.properties):

    hibernate.dataSourceClassName=oracle.jdbc.pool.OracleDataSource
    hibernate.hikari.maximumPoolSize=10
    hibernate.hikari.idleTimeout=30000
    dataSource.url=jdbc:oracle:thin:@localhost:1521:xe
    dataSource.username=admin
    dataSource.password=
    

提交回复
热议问题