c3p0 스프링에서의 설정 과정
1、hibernate에서.properties에 추가:
hibernate.connection.provider_class =org.hibernate.connection.C3P0ConnectionProvider
2、c3p0의 일반적인 설정을 제가 쓴 프로필에 새로 만들었습니다. 이름은 jdbc입니다.properties, c3p0에 대한 코드는 다음과 같습니다.
######C3P0 MySQL config #######
c3p0.url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&mysqlEncoding=utf8
c3p0.user=root
c3p0.password=root
c3p0.driverClass=com.mysql.jdbc.Driver
c3p0.acquireIncrement=1
c3p0.maxIdleTime=60
c3p0.maxPoolSize=200
c3p0.minPoolSize=50
c3p0.initialPoolSize=300
3. 스프링의 DataAccess 구성은 다음과 같습니다.
<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass" value="${c3p0.driverClass}"></property>
<property name="jdbcUrl" value="${c3p0.url}"></property>
<property name="user" value="${c3p0.user}"></property>
<property name="password" value="${c3p0.password}"></property>
<property name="acquireIncrement" value="${c3p0.acquireIncrement}"></property>
<property name="initialPoolSize" value="${c3p0.initialPoolSize}"></property>
<property name="maxIdleTime" value="${c3p0.maxIdleTime}"></property>
<property name="maxPoolSize" value="${c3p0.maxPoolSize}"></property>
<property name="minPoolSize" value="${c3p0.minPoolSize}"></property>
<property name="acquireRetryDelay" value="1000"></property>
<property name="acquireRetryAttempts" value="60"></property>
<property name="breakAfterAcquireFailure" value="false"></property>
</bean>
<!--Hibernate SessionFatory-->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="lobHandler" ref="lobHandler" />
<property name="configLocations">
<list>
<value>classpath*:/hibernate/hibernate.cfg.xml</value>
</list>
</property>
<property name="configurationClass"
value="org.hibernate.cfg.AnnotationConfiguration" />
<!-- hbm
<property name="mappingDirectoryLocations">
<list>
<value>
classpath*:/org/ustb/mis/model/hbm/
</value>
</list>
</property>
-->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
${hibernate.dialect}
</prop>
<prop key="hibernate.show_sql">
${hibernate.show_sql}
</prop>
<prop key="hibernate.cache.use_query_cache">
${hibernate.cache.use_query_cache}
</prop>
<prop key="hibernate.cache.provider_class">
${hibernate.cache.provider_class}
</prop>
<!-- C3P0ConnectionProvider-->
<prop key="hibernate.connection.provider_class">
${hibernate.connection.provider_class}
</prop>
<prop key="hibernate.current_session_context_class">
${hibernate.current_session_context_class}
</prop>
</props>
</property>
</bean>
여기서 등록 정보 파일은 다음과 같이 읽습니다.
<!-- -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath*:hibernate/jdbc.properties</value>
<value>classpath*:hibernate/hibernate.properties</value>
</list>
</property>
</bean>
각 c3p0 속성의 의미와 설정에 대해 많은 글이 언급되었는데 제가 참고한 것은 다음과 같습니다.
http://msq.iteye.com/ 문서: C3P0 연결 풀 상세 구성
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
thymeleaf로 HTML 페이지를 동적으로 만듭니다 (spring + gradle)지난번에는 에서 화면에 HTML을 표시했습니다. 이번에는 화면을 동적으로 움직여보고 싶기 때문에 입력한 문자를 화면에 표시시키고 싶습니다. 초보자의 비망록이므로 이상한 점 등 있으면 지적 받을 수 있으면 기쁩니다! ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.