开发者社区> 问答> 正文

java c3p0 tomcat 关闭的时候出现问题,内存泄露,不能完全释放数据库链接?报错

多数据源路由,在关闭tomcat 的时候,c3p0报错,不能释放全部的数据库链接,多启动几次数据库链接就被耗尽了。

报错如下

[2018-05-21 11:44:51,430 localhost-startStop-1 com.caland.sun.client.SunSqlMapClientTemplate->944] shutdown executors of SunSqlMapClientTemplate... 
[2018-05-21 11:44:51,433 localhost-startStop-1 com.caland.sun.client.SunSqlMapClientTemplate->959] all of the executor services in SunSqlMapClientTemplate are disposed. 
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc
SEVERE: The web application [/mdb] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [Timer-1] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [Timer-2] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [Timer-3] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [Timer-4] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [Timer-5] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [Timer-6] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [Timer-7] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/mdb] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2] but has failed to stop it. This is very likely to create a memory leak.
五月 21, 2018 11:45:01 上午 org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-bio-8080"]
五月 21, 2018 11:45:01 上午 org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["ajp-bio-8009"]
五月 21, 2018 11:45:01 上午 org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-bio-8080"]
五月 21, 2018 11:45:01 上午 org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-bio-8009"]

 

 

展开
收起
爱吃鱼的程序员 2020-06-07 16:19:22 1131 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB
                        <p>配置如下</p> 
    
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    	http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
    	http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
    	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
    	default-lazy-init="true">
    
    	<!-- 使用Annotation自动注册Bean,解决事物失效问题:在主容器中不扫描@Controller注解,在SpringMvc中只扫描@Controller注解。 -->
    	<context:component-scan base-package="com"><!-- base-package 如果多个,用“,”分隔 -->
    		<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
    	</context:component-scan>
    
    	<context:annotation-config />
    	<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    		<property name="location">
    			<value>classpath:/jdbc.properties</value>
    		</property>
    	</bean>
    
    	<!-- 配置数据源开始 -->
    	<bean id="dataSources" class="com.caland.sun.client.datasources.DefaultDataSourceService">
    		<property name="dataSourceDescriptors">
    			<set>
    				<bean class="com.caland.sun.client.datasources.DataSourceDescriptor">
    					<property name="identity" value="partitionLocal" />
    					<property name="targetDataSource" ref="dataSourceLocal" />
    					<property name="targetDetectorDataSource" ref="dataSourceLocal" />
    					<property name="standbyDataSource" ref="dataSourceLocal" />
    					<property name="standbyDetectorDataSource" ref="dataSourceLocal" />
    				</bean>
    				<bean class="com.caland.sun.client.datasources.DataSourceDescriptor">
    					<property name="identity" value="partition2016" />
    					<property name="targetDataSource" ref="dataSource2016" />
    					<property name="targetDetectorDataSource" ref="dataSource2016" />
    					<property name="standbyDataSource" ref="dataSource2016" />
    					<property name="standbyDetectorDataSource" ref="dataSource2016" />
    				</bean>
    				<bean class="com.caland.sun.client.datasources.DataSourceDescriptor">
    					<property name="identity" value="partition2017" />
    					<property name="targetDataSource" ref="dataSource2017" />
    					<property name="targetDetectorDataSource" ref="dataSource2017" />
    					<property name="standbyDataSource" ref="dataSource2017" />
    					<property name="standbyDetectorDataSource" ref="dataSource2017" />
    				</bean>
    				<bean class="com.caland.sun.client.datasources.DataSourceDescriptor">
    					<property name="identity" value="partition2018" />
    					<property name="targetDataSource" ref="dataSource2018" />
    					<property name="targetDetectorDataSource" ref="dataSource2018" />
    					<property name="standbyDataSource" ref="dataSource2018" />
    					<property name="standbyDetectorDataSource" ref="dataSource2018" />
    				</bean>
    				<bean class="com.caland.sun.client.datasources.DataSourceDescriptor">
    					<property name="identity" value="partition2019" />
    					<property name="targetDataSource" ref="dataSource2019" />
    					<property name="targetDetectorDataSource" ref="dataSource2019" />
    					<property name="standbyDataSource" ref="dataSource2019" />
    					<property name="standbyDetectorDataSource" ref="dataSource2019" />
    				</bean>
    				<bean class="com.caland.sun.client.datasources.DataSourceDescriptor">
    					<property name="identity" value="partition2020" />
    					<property name="targetDataSource" ref="dataSource2020" />
    					<property name="targetDetectorDataSource" ref="dataSource2020" />
    					<property name="standbyDataSource" ref="dataSource2020" />
    					<property name="standbyDetectorDataSource" ref="dataSource2020" />
    				</bean>
    				<bean class="com.caland.sun.client.datasources.DataSourceDescriptor">
    					<property name="identity" value="partition2021" />
    					<property name="targetDataSource" ref="dataSource2021" />
    					<property name="targetDetectorDataSource" ref="dataSource2021" />
    					<property name="standbyDataSource" ref="dataSource2021" />
    					<property name="standbyDetectorDataSource" ref="dataSource2021" />
    				</bean>
    				<bean class="com.caland.sun.client.datasources.DataSourceDescriptor">
    					<property name="identity" value="partition2022" />
    					<property name="targetDataSource" ref="dataSource2022" />
    					<property name="targetDetectorDataSource" ref="dataSource2022" />
    					<property name="standbyDataSource" ref="dataSource2022" />
    					<property name="standbyDetectorDataSource" ref="dataSource2022" />
    				</bean>
    			</set>
    		</property>
    		<property name="haDataSourceCreator">
    			<bean class="com.caland.sun.client.datasources.ha.FailoverHotSwapDataSourceCreator">
    				<property name="detectingSql" value="update caland set timeflag=CURRENT_TIMESTAMP()" />
    			</bean>
    		</property>
    	</bean>
    
    	<!-- 本地数据源 -->
    	<bean id="dataSourceLocal" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    		<property name="driverClass" value="${jdbc.driverClassName}" />
    		<property name="jdbcUrl" value="${jdbc0.url}" />
    		<property name="user" value="${jdbc0.username}" />
    		<property name="password" value="${jdbc0.password}" />
    		<property name="autoCommitOnClose" value="true" />
    		<!-- <property name="checkoutTimeout" value="${cpool.checkoutTimeout}"/> -->
    		<property name="initialPoolSize" value="${cpool.minPoolSize}" />
    		<property name="minPoolSize" value="${cpool.minPoolSize}" />
    		<property name="maxPoolSize" value="${cpool.maxPoolSize}" />
    		<property name="maxIdleTime" value="${cpool.maxIdleTime}" />
    		<property name="acquireIncrement" value="${cpool.acquireIncrement}" />
    		<property name="maxIdleTimeExcessConnections" value="${cpool.maxIdleTimeExcessConnections}" />
    	</bean>
    	
    	<!-- 数据源1 -->
    	<bean id="dataSource2016" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    		<property name="driverClass" value="${jdbc.driverClassName}" />
    		<property name="jdbcUrl" value="${jdbc1.url}" />
    		<property name="user" value="${jdbc1.username}" />
    		<property name="password" value="${jdbc1.password}" />
    		<property name="autoCommitOnClose" value="true" />
    		<!-- <property name="checkoutTimeout" value="${cpool.checkoutTimeout}"/> -->
    		<property name="initialPoolSize" value="${cpool.minPoolSize}" />
    		<property name="minPoolSize" value="${cpool.minPoolSize}" />
    		<property name="maxPoolSize" value="${cpool.maxPoolSize}" />
    		<property name="maxIdleTime" value="${cpool.maxIdleTime}" />
    		<property name="acquireIncrement" value="${cpool.acquireIncrement}" />
    		<property name="maxIdleTimeExcessConnections" value="${cpool.maxIdleTimeExcessConnections}" />
    	</bean>
    
    	<!-- 数据源2 -->
    	<bean id="dataSource2017" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    		<property name="driverClass" value="${jdbc.driverClassName}" />
    		<property name="jdbcUrl" value="${jdbc2.url}" />
    		<property name="user" value="${jdbc2.username}" />
    		<property name="password" value="${jdbc2.password}" />
    		<property name="autoCommitOnClose" value="true" />
    		<!-- <property name="checkoutTimeout" value="${cpool.checkoutTimeout}"/> -->
    		<property name="initialPoolSize" value="${cpool.minPoolSize}" />
    		<property name="minPoolSize" value="${cpool.minPoolSize}" />
    		<property name="maxPoolSize" value="${cpool.maxPoolSize}" />
    		<property name="maxIdleTime" value="${cpool.maxIdleTime}" />
    		<property name="acquireIncrement" value="${cpool.acquireIncrement}" />
    		<property name="maxIdleTimeExcessConnections" value="${cpool.maxIdleTimeExcessConnections}" />
    	</bean>
    
    	<!-- 数据源3 -->
    	<bean id="dataSource2018" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    		<property name="driverClass" value="${jdbc.driverClassName}" />
    		<property name="jdbcUrl" value="${jdbc3.url}" />
    		<property name="user" value="${jdbc3.username}" />
    		<property name="password" value="${jdbc3.password}" />
    		<property name="autoCommitOnClose" value="true" />
    		<!-- <property name="checkoutTimeout" value="${cpool.checkoutTimeout}"/> -->
    		<property name="initialPoolSize" value="${cpool.minPoolSize}" />
    		<property name="minPoolSize" value="${cpool.minPoolSize}" />
    		<property name="maxPoolSize" value="${cpool.maxPoolSize}" />
    		<property name="maxIdleTime" value="${cpool.maxIdleTime}" />
    		<property name="acquireIncrement" value="${cpool.acquireIncrement}" />
    		<property name="maxIdleTimeExcessConnections" value="${cpool.maxIdleTimeExcessConnections}" />
    	</bean>
    	<!-- 数据源4 -->
    	<bean id="dataSource2019" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    		<property name="driverClass" value="${jdbc.driverClassName}" />
    		<property name="jdbcUrl" value="${jdbc4.url}" />
    		<property name="user" value="${jdbc4.username}" />
    		<property name="password" value="${jdbc4.password}" />
    		<property name="autoCommitOnClose" value="true" />
    		<!-- <property name="checkoutTimeout" value="${cpool.checkoutTimeout}"/> -->
    		<property name="initialPoolSize" value="${cpool.minPoolSize}" />
    		<property name="minPoolSize" value="${cpool.minPoolSize}" />
    		<property name="maxPoolSize" value="${cpool.maxPoolSize}" />
    		<property name="maxIdleTime" value="${cpool.maxIdleTime}" />
    		<property name="acquireIncrement" value="${cpool.acquireIncrement}" />
    		<property name="maxIdleTimeExcessConnections" value="${cpool.maxIdleTimeExcessConnections}" />
    	</bean>
    	<!-- 数据源5 -->
    	<bean id="dataSource2020" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    		<property name="driverClass" value="${jdbc.driverClassName}" />
    		<property name="jdbcUrl" value="${jdbc5.url}" />
    		<property name="user" value="${jdbc5.username}" />
    		<property name="password" value="${jdbc5.password}" />
    		<property name="autoCommitOnClose" value="true" />
    		<!-- <property name="checkoutTimeout" value="${cpool.checkoutTimeout}"/> -->
    		<property name="initialPoolSize" value="${cpool.minPoolSize}" />
    		<property name="minPoolSize" value="${cpool.minPoolSize}" />
    		<property name="maxPoolSize" value="${cpool.maxPoolSize}" />
    		<property name="maxIdleTime" value="${cpool.maxIdleTime}" />
    		<property name="acquireIncrement" value="${cpool.acquireIncrement}" />
    		<property name="maxIdleTimeExcessConnections" value="${cpool.maxIdleTimeExcessConnections}" />
    	</bean>
    	<!-- 数据源6 -->
    	<bean id="dataSource2021" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    		<property name="driverClass" value="${jdbc.driverClassName}" />
    		<property name="jdbcUrl" value="${jdbc6.url}" />
    		<property name="user" value="${jdbc6.username}" />
    		<property name="password" value="${jdbc6.password}" />
    		<property name="autoCommitOnClose" value="true" />
    		<!-- <property name="checkoutTimeout" value="${cpool.checkoutTimeout}"/> -->
    		<property name="initialPoolSize" value="${cpool.minPoolSize}" />
    		<property name="minPoolSize" value="${cpool.minPoolSize}" />
    		<property name="maxPoolSize" value="${cpool.maxPoolSize}" />
    		<property name="maxIdleTime" value="${cpool.maxIdleTime}" />
    		<property name="acquireIncrement" value="${cpool.acquireIncrement}" />
    		<property name="maxIdleTimeExcessConnections" value="${cpool.maxIdleTimeExcessConnections}" />
    	</bean>
    	<!-- 数据源7 -->
    	<bean id="dataSource2022" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    		<property name="driverClass" value="${jdbc.driverClassName}" />
    		<property name="jdbcUrl" value="${jdbc7.url}" />
    		<property name="user" value="${jdbc7.username}" />
    		<property name="password" value="${jdbc7.password}" />
    		<property name="autoCommitOnClose" value="true" />
    		<!-- <property name="checkoutTimeout" value="${cpool.checkoutTimeout}"/> -->
    		<property name="initialPoolSize" value="${cpool.minPoolSize}" />
    		<property name="minPoolSize" value="${cpool.minPoolSize}" />
    		<property name="maxPoolSize" value="${cpool.maxPoolSize}" />
    		<property name="maxIdleTime" value="${cpool.maxIdleTime}" />
    		<property name="acquireIncrement" value="${cpool.acquireIncrement}" />
    		<property name="maxIdleTimeExcessConnections" value="${cpool.maxIdleTimeExcessConnections}" />
    	</bean>
    	<!-- 配置数据源结束 -->
    
    	<!-- 配置路由规则开始 -->
    	<bean id="hashFunction" class="com.jiumai.carnet.mdb.core.dao.router.HashFunction" />
    	<bean id="internalRouter" class="com.caland.sun.client.router.config.InteralRouterXmlFactoryBean">
    		<!-- functionsMap是在使用自定义路由规则函数的时候使用 -->
    		<property name="functionsMap">
    			<map>
    				<entry key="hash" value-ref="hashFunction"></entry>
    			</map>
    		</property>
    		<property name="configLocations">
    			<list>
    				<value>classpath:/dbRule/sharding-rules-on-namespace.xml</value>
    			</list>
    		</property>
    	</bean>
    	<!-- 配置路由规则结束 -->
    
    	<!-- 事务配置 -->
    	<bean id="transactionManager" class="com.caland.sun.client.transaction.MultipleDataSourcesTransactionManager">
    		<property name="dataSourceService" ref="dataSources" />
    		<property name="transactionSynchronization" value="2" />
    	</bean>
    
    	<!-- 使用annotation定义事务 -->
    	<tx:annotation-driven transaction-manager="transactionManager" />
    
    	<!-- iBatis SQL map定义。 -->
    	<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
    		<!-- 这里配置的dataSource0为默认的数据源,如果找不到数据库的话则到该数据源中查找 -->
    		<property name="dataSource" ref="dataSource2017" />
    		<property name="configLocation">
    			<value>classpath:/sqlmap-config.xml</value>
    		</property>
    	</bean>
    
    	<!-- 工程里一定要使用此工程模板,不能再使用ibatis原生的api,不然有的情况会不经过的过滤 -->
    	<bean id="sqlMapClientTemplate" class="com.caland.sun.client.SunSqlMapClientTemplate">
    		<property name="sqlMapClient" ref="sqlMapClient" />
    		<property name="dataSourceService" ref="dataSources" />
    		<property name="router" ref="internalRouter" />
    		<property name="sqlAuditor">
    			<bean class="com.caland.sun.client.audit.SimpleSqlAuditor" />
    		</property>
    		<property name="profileLongTimeRunningSql" value="true" />
    		<property name="longTimeRunningSqlIntervalThreshold" value="3600000" />
    	</bean>
    	
    	<import resource="classpath*:spring-quartz.xml" />
    </beans>

     

                        <p>可能需要把MYSQL的jdbc驱动放到tomcat 的lib下面,项目中不要包含mysql驱动,这个问题应该是tomcat运行多个应用会出现这个问题,单个应用应该不会。这是我的一个猜测</p>
    
                    
    
                            tomcat 里只有一个应用,奇怪的是,我的伙伴们启动都很正常,就是我的电脑有问题,而且,把数据换换成我本地的就没有问题,换局域网的就会出现链接没有释放
                        
    
                        <p>我觉得这篇文章说的很有可能</p>
    

    https://www.cnblogs.com/wangxinblog/p/7376469.html

                            不是这个问题,现在报错的信息已经解决。
                        
    
                        <p>c3p0的数据库连接,你用完后是否关闭了?关闭数据库连接池的连接不是真正意义上的关闭,而是重写实现,把其放入到连接池中。只要是数据库连接就要急着关闭。</p>
    
                    
    
                            我电脑都重启了,然而mysql上 还有上次启动程序初始化的120个链接没有释放
                        
    
                                回复 <a class="referer" target="_blank">@soulCoke</a>  : 如果看到还存在java相关进程,且关闭后数据库连接被释放,那么可能是tomcat未完全成功关闭。
                        
    
                                回复 <a class="referer" target="_blank">@soulCoke</a>  : 关闭tomcat后再查看一下java相关进程呢?如果有就强制关闭进程。
                        
    
                            我直接关闭了tomcat,不存在用不用啊,现在只希望他能把所有的链接释放掉,因为我已经把程序关闭了。实际情况是mysql 有许多链接没有被释放
                        
    
                        <p>本地虽然报错,但是链接是完全可以释放的,连局域网的开发环境就不能完全释放</p>
    
                    
    
                        <p>报错的问题已经解决,是因为定义了一个检查sql ,时刻在请求,最后停止的时候,事务没有提交,报错。</p>
    

    。 改成select 1 from dual . 现在程序一切正常,关闭的时候也不报错,但是就是不明白为什么数据库链接为什么不释放,只存在我电脑上,其他小伙伴上运行正常,可以正常回收。

    2020-06-07 16:19:34
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Apache Tomcat 的云原生演进 立即下载
内存取证与IaaS云平台恶意行 为的安全监控 立即下载
云服务器ECS内存增强型实例re6全新发布 立即下载