C3P0的连接池(解决Mysql 链接只有8小时的问题)(二)

上一篇 / 下一篇  2011-10-31 15:58:36 / 个人分类:测试环境的搭建

在{JBOSS_HOME}\server\default\deploy目录下新建 c3p0-service.xml 文件;文件内容如下
<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE server> 
<server>
    
<mbean code="com.mchange.v2.c3p0.jboss.C3P0PooledDataSource" name="jboss:service=C3P0PooledDataSourceOKMWorkflowDS">
    
<attribute name="JndiName">java:OKMWorkflowDS</attribute>
    
<attribute name="JdbcUrl">jdbc:mysql://localhost:3306/openkm</attribute>
    
<attribute name="DriverClass">com.mysql.jdbc.Driver</attribute>
    
<attribute name="User">root</attribute>
    
<attribute name="Password">123456</attribute>  
    
<!-- Uncomment and set any of the optional parameters below -->  
    
<!-- See c3p0's docs for more info. -->  
    
<attribute name="AcquireIncrement">2</attribute>  
    
<attribute name="AcquireRetryAttempts">30</attribute>  
    
<!-- <attribute name="AcquireRetryDelay">1000</attribute> -->  
    
<!-- <attribute name="AutoCommitOnClose">false</attribute> -->  
    
<!-- <attribute name="AutomaticTestTable"></attribute> -->  
    
<attribute name="BreakAfterAcquireFailure">true</attribute> 
    
<!-- <attribute name="CheckoutTimeout">0</attribute> -->  
    
<!-- <attribute name="ConnectionCustomizerClassName"></attribute> -->  
    
<!-- <attribute name="ConnectionTesterClassName"></attribute> -->  
    
<!-- <attribute name="Description">A pooled c3p0 DataSource</attribute> -->  
    
<!-- <attribute name="DebugUnreturnedConnectionStackTraces">false</attribute> -->  
    
<!-- <attribute name="FactoryClassLocation"></attribute> -->  
    
<!-- <attribute name="ForceIgnoreUnresolvedTransactions">false</attribute> -->  
    
<attribute name="IdleConnectionTestPeriod">40</attribute>  
    
<attribute name="InitialPoolSize">2</attribute>  
    
<!-- <attribute name="MaxAdministrativeTaskTime">0</attribute> -->  
    
<!-- <attribute name="MaxConnectionAge">0</attribute> -->  
    
<attribute name="MaxIdleTime">1800</attribute>
    
<!-- <attribute name="MaxIdleTimeExcessConnections">0</attribute> -->  
    
<attribute name="MaxPoolSize">15</attribute>  
    
<attribute name="MaxStatements">0</attribute> 
    
<!-- <attribute name="MaxStatementsPerConnection">0</attribute> -->  
    
<attribute name="MinPoolSize">1</attribute> 
    
<!-- <attribute name="NumHelperThreads">3</attribute> -->  
    
<!-- <attribute name="PreferredTestQuery"></attribute> -->  
    
<!-- <attribute name="TestConnectionOnCheckin">false</attribute> -->  
    
<attribute name="TestConnectionOnCheckout">false</attribute> 
    
<!-- <attribute name="UnreturnedConnectionTimeout">0</attribute> -->  
    
<!-- <attribute name="UsesTraditionalReflectiveProxies">false</attribute> -->  
    
<depends>jboss:service=Naming</depends>  
    
</mbean>
    
<mbean code="com.mchange.v2.c3p0.jboss.C3P0PooledDataSource" name="jboss:service=C3P0PooledDataSourceOKMDashboardStatsDS">
    
<attribute name="JndiName">java:OKMDashboardStatsDS</attribute>
    
<attribute name="JdbcUrl">jdbc:mysql://localhost:3306/openkm</attribute>
    
<attribute name="DriverClass">com.mysql.jdbc.Driver</attribute>
    
<attribute name="User">root</attribute>
    
<attribute name="Password">123456</attribute>  
    
<!-- Uncomment and set any of the optional parameters below -->  
    
<!-- See c3p0's docs for more info. -->  
    
<attribute name="AcquireIncrement">2</attribute>  
    
<attribute name="AcquireRetryAttempts">30</attribute>  
    
<!-- <attribute name="AcquireRetryDelay">1000</attribute> -->  
    
<!-- <attribute name="AutoCommitOnClose">false</attribute> -->  
    
<!-- <attribute name="AutomaticTestTable"></attribute> -->  
    
<attribute name="BreakAfterAcquireFailure">true</attribute> 
    
<!-- <attribute name="CheckoutTimeout">0</attribute> -->  
    
<!-- <attribute name="ConnectionCustomizerClassName"></attribute> -->  
    
<!-- <attribute name="ConnectionTesterClassName"></attribute> -->  
    
<!-- <attribute name="Description">A pooled c3p0 DataSource</attribute> -->  
    
<!-- <attribute name="DebugUnreturnedConnectionStackTraces">false</attribute> -->  
    
<!-- <attribute name="FactoryClassLocation"></attribute> -->  
    
<!-- <attribute name="ForceIgnoreUnresolvedTransactions">false</attribute> -->  
    
<attribute name="IdleConnectionTestPeriod">40</attribute>  
    
<attribute name="InitialPoolSize">2</attribute>  
    
<!-- <attribute name="MaxAdministrativeTaskTime">0</attribute> -->  
    
<!-- <attribute name="MaxConnectionAge">0</attribute> -->  
    
<attribute name="MaxIdleTime">1800</attribute>
    
<!-- <attribute name="MaxIdleTimeExcessConnections">0</attribute> -->  
    
<attribute name="MaxPoolSize">15</attribute>  
    
<attribute name="MaxStatements">0</attribute> 
    
<!-- <attribute name="MaxStatementsPerConnection">0</attribute> -->  
    
<attribute name="MinPoolSize">1</attribute> 
    
<!-- <attribute name="NumHelperThreads">3</attribute> -->  
    
<!-- <attribute name="PreferredTestQuery"></attribute> -->  
    
<!-- <attribute name="TestConnectionOnCheckin">false</attribute> -->  
    
<attribute name="TestConnectionOnCheckout">false</attribute> 
    
<!-- <attribute name="UnreturnedConnectionTimeout">0</attribute> -->  
    
<!-- <attribute name="UsesTraditionalReflectiveProxies">false</attribute> -->  
    
<depends>jboss:service=Naming</depends>  
    
</mbean> 
    
<mbean code="com.mchange.v2.c3p0.jboss.C3P0PooledDataSource" name="jboss:service=C3P0PooledDataSourceOKMAuthDS">
    
<attribute name="JndiName">java:OKMAuthDS</attribute>
    
<attribute name="JdbcUrl">jdbc:mysql://localhost:3306/openkm</attribute>
    
<attribute name="DriverClass">com.mysql.jdbc.Driver</attribute>
    
<attribute name="User">root</attribute>
    
<attribute name="Password">123456</attribute>  
    
<!-- Uncomment and set any of the optional parameters below -->  
    
<!-- See c3p0's docs for more info. -->  
    
<attribute name="AcquireIncrement">2</attribute>  
    
<attribute name="AcquireRetryAttempts">30</attribute>  
    
<!-- <attribute name="AcquireRetryDelay">1000</attribute> -->  
    
<!-- <attribute name="AutoCommitOnClose">false</attribute> -->  
    
<!-- <attribute name="AutomaticTestTable"></attribute> -->  
    
<attribute name="BreakAfterAcquireFailure">true</attribute> 
    
<!-- <attribute name="CheckoutTimeout">0</attribute> -->  
    
<!-- <attribute name="ConnectionCustomizerClassName"></attribute> -->  
    
<!-- <attribute name="ConnectionTesterClassName"></attribute> -->  
    
<!-- <attribute name="Description">A pooled c3p0 DataSource</attribute> -->  
    
<!-- <attribute name="DebugUnreturnedConnectionStackTraces">false</attribute> -->  
    
<!-- <attribute name="FactoryClassLocation"></attribute> -->  
    
<!-- <attribute name="ForceIgnoreUnresolvedTransactions">false</attribute> -->  
    
<attribute name="IdleConnectionTestPeriod">40</attribute>  
    
<attribute name="InitialPoolSize">2</attribute>  
    
<!-- <attribute name="MaxAdministrativeTaskTime">0</attribute> -->  
    
<!-- <attribute name="MaxConnectionAge">0</attribute> -->  
    
<attribute name="MaxIdleTime">1800</attribute>
    
<!-- <attribute name="MaxIdleTimeExcessConnections">0</attribute> -->  
    
<attribute name="MaxPoolSize">15</attribute>  
    
<attribute name="MaxStatements">0</attribute> 
    
<!-- <attribute name="MaxStatementsPerConnection">0</attribute> -->  
    
<attribute name="MinPoolSize">1</attribute> 
    
<!-- <attribute name="NumHelperThreads">3</attribute> -->  
    
<!-- <attribute name="PreferredTestQuery"></attribute> -->  
    
<!-- <attribute name="TestConnectionOnCheckin">false</attribute> -->  
    
<attribute name="TestConnectionOnCheckout">false</attribute> 
    
<!-- <attribute name="UnreturnedConnectionTimeout">0</attribute> -->  
    
<!-- <attribute name="UsesTraditionalReflectiveProxies">false</attribute> -->  
    
<depends>jboss:service=Naming</depends>  
    
</mbean> 
    
<mbean code="com.mchange.v2.c3p0.jboss.C3P0PooledDataSource" name="jboss:service=C3P0PooledDataSourceOKMActivityDS">
    
<attribute name="JndiName">java:OKMActivityDS</attribute>
    
<attribute name="JdbcUrl">jdbc:mysql://localhost:3306/openkm</attribute>
    
<attribute name="DriverClass">com.mysql.jdbc.Driver</attribute>
    
<attribute name="User">root</attribute>
    
<attribute name="Password">123456</attribute>  
    
<!-- Uncomment and set any of the optional parameters below -->  
    
<!-- See c3p0's docs for more info. -->  
    
<attribute name="AcquireIncrement">2</attribute>  
    
<attribute name="AcquireRetryAttempts">30</attribute>  
    
<!-- <attribute name="AcquireRetryDelay">1000</attribute> -->  
    
<!-- <attribute name="AutoCommitOnClose">false</attribute> -->  
    
<!-- <attribute name="AutomaticTestTable"></attribute> -->  
    
<attribute name="BreakAfterAcquireFailure">true</attribute> 
    
<!-- <attribute name="CheckoutTimeout">0</attribute> -->  
    
<!-- <attribute name="ConnectionCustomizerClassName"></attribute> -->  
    
<!-- <attribute name="ConnectionTesterClassName"></attribute> -->  
    
<!-- <attribute name="Description">A pooled c3p0 DataSource</attribute> -->  
    
<!-- <attribute name="DebugUnreturnedConnectionStackTraces">false</attribute> -->  
    
<!-- <attribute name="FactoryClassLocation"></attribute> -->  
    
<!-- <attribute name="ForceIgnoreUnresolvedTransactions">false</attribute> -->  
    
<attribute name="IdleConnectionTestPeriod">40</attribute>  
    
<attribute name="InitialPoolSize">2</attribute>  
    
<!-- <attribute name="MaxAdministrativeTaskTime">0</attribute> -->  
    
<!-- <attribute name="MaxConnectionAge">0</attribute> -->  
    
<attribute name="MaxIdleTime">1800</attribute>
    
<!-- <attribute name="MaxIdleTimeExcessConnections">0</attribute> -->  
    
<attribute name="MaxPoolSize">15</attribute>  
    
<attribute name="MaxStatements">0</attribute> 
    
<!-- <attribute name="MaxStatementsPerConnection">0</attribute> -->  
    
<attribute name="MinPoolSize">1</attribute> 
    
<!-- <attribute name="NumHelperThreads">3</attribute> -->  
    
<!-- <attribute name="PreferredTestQuery"></attribute> -->  
    
<!-- <attribute name="TestConnectionOnCheckin">false</attribute> -->  
    
<attribute name="TestConnectionOnCheckout">false</attribute> 
    
<!-- <attribute name="UnreturnedConnectionTimeout">0</attribute> -->  
    
<!-- <attribute name="UsesTraditionalReflectiveProxies">false</attribute> -->  
    
<depends>jboss:service=Naming</depends>  
    
</mbean> 
    
</server>

最后一步,把C3P0的JAR c3p0-09.1.11.jar COPY 到{JBOSS_HOME}\server\default\lib 目录下即可。

TAG:

 

评分:0

我来说两句

Open Toolbar