Java – configure spring data sources for hibernate and @ transactional
•
Java
At this time, I am using the drivermanagerdatasource with @ transactional annotation to manage transactions But all transactions are very slow, probably because the data source opens and closes the connection to DB every time
What data sources should I use to accelerate transactions?
Solution
The drivermanagerdatasource is not actually a connection pool and should only be used for testing You should try basicdatasource. Starting with Apache commons DBCP be similar to:
<bean id="dataSource" destroy-method="close"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
