开发者社区> 问答> 正文

阿里云的RDS能否使用DruidDataSource连接池并开启GTS

使用GTS时,我想使用RDS数据库,加上DruidDataSource连接池, 不过文档上好像说要使用GTS 提供的数据源包。 这个数据源包是一定要com.taobao.txc.datasource.cobar.TxcDataSource还是com.alibaba.druid.pool.DruidDataSource 也可以?

展开
收起
john_k 2017-07-21 17:38:13 4225 0
1 条回答
写回答
取消 提交回答
  • GTS

    使用 GTS 必须使用 TxcDataSource 来包装 DruidDataSource:

        <bean id="txcDataSource" class="com.taobao.txc.datasource.cobar.TxcDataSource">
            <constructor-arg ref="druidDataSource"/>
        </bean>
    
        <bean id="druidDataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init">
            <property name="url" value="jdbc:mysql://xxxxxxxxx:3306/xxx"/>
            <property name="username" value="xxx"/>
            <property name="connectProperties">
                <props>
                    <prop key="password">xxx</prop>
                </props>
            </property>
            <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
            <property name="filters" value="stat" />
            <property name="maxActive" value="300" />
            <property name="initialSize" value="10" />
            <property name="maxWait" value="60000" />
            <property name="minIdle" value="1" />
            <property name="timeBetweenEvictionRunsMillis" value="60000" />
            <property name="minEvictableIdleTimeMillis" value="300000" />
            <property name="validationQuery" value="SELECT 'x'" />
            <property name="testWhileIdle" value="true" />
            <property name="testOnBorrow" value="false" />
            <property name="testOnReturn" value="false" />
    
            <!-- 不支持Druid SQL cache -->
            <!-- Druid数据源如果被包装在TxcDataSource中,以下配置将被置为无效 -->
            <property name="poolPreparedStatements" value="true" />
            <property name="maxPoolPreparedStatementPerConnectionSize" value="30" />
        </bean>

    相当于在 Druid 数据源上增加了 GTS 分布式事务的能力。

    2019-07-17 21:25:13
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
TcpRT:阿里云RDS智能诊断系统云上大规模部署自动化服务的客户实践经验 立即下载
TcpRT:面向大规模海量云数据库的服务质量实时采集与诊断系 立即下载
袋鼠云基于阿里云RDS的数据库架构实践 立即下载

相关镜像