Solve the deadlock problem of multiple one-to-one relationships (Database Connection Pool c3p0)

Source: Internet
Author: User

Hibernate 1-to-many deadlock
Frequent deadlocks in spring + hibernate + Struts + SQL databases. The query is deadlocked after update is executed.

It's dead. You have to stop tomcat to continue running.

Solution: use the database connection pool c3p0

<Bean id = "datasource" class = "com. mchange. v2.c3p0. combopooleddatasource" Destroy-method = "close">
<Property name = "driverclass" value = "com. Microsoft. JDBC. sqlserver. sqlserverdriver"/>
<Property name = "jdbcurl" value = "JDBC: Microsoft: sqlserver: // localhost: 1433; databasename = bookshop"/>
<! --
<Property name = "user" value = "$ {dB. User}"/>
<Property name = "password" value = "$ {dB. Pass}"/>
-->
<Property name = "properties">
<Props>
<! -- The number of connections that c3p0 obtains at the same time when connections in the connection pool are exhausted. Default: 3 -->
<Prop key = "c3p0. acquire_increment"> 5 </prop>
<! -- Check all idle connections in the connection pool every 60 seconds. Default: 0 -->
<Prop key = "c3p0. idle_test_period"> 60 </prop>
<Prop key = "c3p0. max_size"> 15 </prop>
<Prop key = "c3p0. max_statements"> 0 </prop>
<Prop key = "c3p0. min_size"> 10 </prop>
<Prop key = "user"> SA </prop>
<Prop key = "password"> SA </prop>
</Props>
</Property>
</Bean>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.