• 数据源HikariCP(多数据库的配置项)


    oracle.jdbc.type=oracle
    oracle.jdbc.driver=oracle.jdbc.OracleDriver
    oracle.jdbc.url=jdbc:oracle:thin:@[ip]:[port]:[dbdomain]
    oracle.jdbc.username=[username]
    oracle.jdbc.password=[password]
    
    pi.isUsed=true
    pi.jdbc.type=PI
    pi.jdbc.driver=com.osisoft.jdbc.Driver
    pi.jdbc.url=jdbc:pioledb://localhost/Data Source=[PI Server Address]; Integrated Security=SSPI/
        <!-- Hikari Datasource -->
        <bean id="dataSource_Oracle" class="com.zaxxer.hikari.HikariDataSource"
            destroy-method="close">
            <property name="driverClassName" value="${oracle.jdbc.driver}" /><!-- 
                无需指定,除非系统无法自动识别 -->
            <property name="jdbcUrl" value="${oracle.jdbc.url}" />
            <property name="username" value="${oracle.jdbc.username}" />
            <property name="password" value="${oracle.jdbc.password}" />
            <property name="maximumPoolSize" value="100" />
            <property name="minimumIdle" value="10" />
            <property name="connectionTestQuery" value="select 1 from dual" />
            <property name="dataSourceProperties">
                <props>
                    <prop key="cachePrepStmts">true</prop>
                    <prop key="prepStmtCacheSize">250</prop>
                    <prop key="prepStmtCacheSqlLimit">2048</prop>
                    <prop key="useServerPrepStmts">true</prop>
                </props>
            </property>
        </bean>
    
        <bean id="dataSource_PI" class="com.zaxxer.hikari.HikariDataSource"
            destroy-method="close">
            <property name="driverClassName" value="${pi.jdbc.driver}" />
            <property name="jdbcUrl" value="${pi.jdbc.url}" />
            <property name="maximumPoolSize" value="100" />  
            <property name="minimumIdle" value="10" />
            <property name="dataSourceProperties">  
                <props>  
                    <prop key="cachePrepStmts">true</prop>  
                    <prop key="prepStmtCacheSize">250</prop>  
                    <prop key="prepStmtCacheSqlLimit">2048</prop>  
                    <prop key="useServerPrepStmts">true</prop>  
                </props>  
            </property>  
        </bean>
    
        <bean id="dataSource" class="com.bkc.bpmp.core.datasource.DynamicDataSource">
            <property name="targetDataSources">
                <map key-type="java.lang.String">
                    <entry key="dataSource_Oracle" value-ref="dataSource_Oracle" />
                    <entry key="dataSource_PI" value-ref="dataSource_PI" />
                </map>
            </property>
            <property name="defaultTargetDataSource" ref="dataSource_Oracle" />
        </bean>

    关于多数据源的详细使用,查看其它帖子。这里只是为了表示 采用 HikariCP 时,Spring配置文件是如何写的。

  • 相关阅读:
    HOWTO re
    数据类型
    字符串
    最大公约数
    this
    tip 2:找最小公倍数之Boost
    tip 1:一个简单的将int型转换成char的方法
    Item47
    成员函数模板
    item44:将与参数无关的代码抽离template
  • 原文地址:https://www.cnblogs.com/panie2015/p/7866868.html
Copyright © 2020-2023  润新知