本站使用了 Disqus 评论框,如需留言请扶墙

Hibernate几种连接MYSQL方式

这些连接配置 都解决了 连接MYSQL长时间空连接情况被mysql断开后无法再次连接的问题(8小时坑爹案例)

方法1

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">  
     <property name="driverClass" value="com.mysql.jdbc.Driver" />
     <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/sspanel" />
     <property name="user" value="root" />
     <property name="password" value="root" />
     <property name="minPoolSize" value="10" />
     <property name="maxPoolSize" value="100" />
     <property name="maxIdleTime" value="1800" />
     <property name="acquireIncrement" value="3" />
     <property name="maxStatements" value="1000" />
     <property name="initialPoolSize" value="10" />
     <property name="idleConnectionTestPeriod" value="60" />
     <property name="acquireRetryAttempts" value="30" />
     <property name="breakAfterAcquireFailure" value="true" />
     <property name="testConnectionOnCheckout" value="false" />
</bean>  

方法2

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">  
      <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
      <property name="url" value="jdbc:mysql://localhost:3306/sspanel" />
      <property name="username" value="root" />
      <property name="password" value="root" />
      <property name="maxWait" value="20000" />
      <property name="validationQuery" value="SELECT 1" />
      <property name="testWhileIdle" value="true" />
      <property name="testOnBorrow" value="true" />
      <property name="timeBetweenEvictionRunsMillis" value="3600000" />
      <property name="numTestsPerEvictionRun" value="50" />
      <property name="minEvictableIdleTimeMillis" value="120000" />
      <property name="removeAbandoned" value="true" />
      <property name="removeAbandonedTimeout" value="6000000"/>
</bean>  

Sendya

又穷又屌丝又不会英语 写什么 Bio

Amoy, china.