Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alibaba druid 的连接池配置示例有吗? #4

Open
marsal1212 opened this issue Feb 1, 2018 · 3 comments
Open

alibaba druid 的连接池配置示例有吗? #4

marsal1212 opened this issue Feb 1, 2018 · 3 comments

Comments

@marsal1212
Copy link

No description provided.

@liuyangming
Copy link
Owner

阿里druid对XA的支持做的不好,建议使用commons-dbcp。

@marsal1212
Copy link
Author

用LocalXADataSource包裹druidDataSource这种写法会有什么问题吗?这种配置已经跑通了列子,且事务支持正常。

        <bean id="dataSource3" class="org.bytesoft.bytejta.supports.jdbc.LocalXADataSource">
		<property name="dataSource" ref="druidDataSource" />
	</bean>

	<bean id="druidDataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
		<!-- 基本属性 url、user、password -->
		
		<property name="url" value="jdbc:mysql://127.0.0.1:3306/inst01" />
		<property name="username" value="root" />
		<property name="password" value="zzz" />

		<!-- 配置初始化大小、最小、最大 -->
		<property name="initialSize" value="1" />
		<property name="minIdle" value="1" />
		<property name="maxActive" value="20" />

		<!-- 配置获取连接等待超时的时间 -->
		<property name="maxWait" value="60000" />

		<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
		<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" />

		<!-- 打开PSCache,并且指定每个连接上PSCache的大小 -->
		<property name="poolPreparedStatements" value="true" />
		<property name="maxPoolPreparedStatementPerConnectionSize" value="20" />

		<!-- 配置监控统计拦截的filters -->
		<property name="filters" value="stat" />
	</bean>

	<bean id="jdbcTemplate3" class="org.springframework.jdbc.core.JdbcTemplate">
		<property name="dataSource" ref="dataSource3" />
	</bean>

@liuyangming
Copy link
Owner

liuyangming commented Feb 1, 2018

LocalXADataSource封装的是DataSource,不是XADataSource。在一个全局事务中,ByteJTA只支持一个non-XA资源参与。
所以,如果只有一个资源参与全局事务,这样写是没问题的;如果有多个资源参与全局事务,还是需要使用XADataSource。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants