`
longgangbai
  • 浏览: 7330348 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

XApool连接池那些坑爹的问题

阅读更多

        最近项目需要使用到Oracle和Mysql操作一些数据库为了操作业务事务一致性,采用JTA事务处理跨数据库的事务,采用JOTM,但是出现一些列问题。

主要配置applicationContext-datasource.xml

<?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:tx="http://www.springframework.org/schema/tx"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:p="http://www.springframework.org/schema/p"
	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/context http://www.springframework.org/schema/context/spring-context-3.0.xsd 
		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
	<!--指定Spring配置中用到的属性文件 -->
	<bean id="propertyConfig"
		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="locations">
			<list>
				<value>classpath:jdbc.properties</value>
			</list>
		</property>
	</bean>
	<!-- 数据源A -->
	<bean id="mysqlJta" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource"		destroy-method="shutdown">
		<property name="dataSource">
				<bean id="mysqlJtaDS" class="org.enhydra.jdbc.standard.StandardXADataSource"		destroy-method="shutdown">
				<property name="transactionManager">
					<ref bean="jotm" />
				</property>
				<property name="driverName" value="${jdbc.driver}" />
				<property name="url" value="${jdbc.url}" />
				<property name="user" value="${jdbc.username}" />
				<property name="password" value="${jdbc.password}" />
				<property name="minCon" value="1" />
			</bean>
		</property>
		<property name="transactionManager">
			<ref bean="jotm" />
		</property>
		<property name="maxSize">
			<value>10</value>
		</property>
		<property name="user" value="${jdbc.username}" />
		<property name="password" value="${jdbc.password}" />
	</bean>



	<!-- 数据源B -->
	<bean id="oracleJta" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource" destroy-method="shutdown">
		<property name="dataSource">
				<bean id="oracleJtaDS" class="org.enhydra.jdbc.standard.StandardXADataSource"		destroy-method="shutdown">
					<property name="transactionManager">
						<ref bean="jotm" />
					</property>
					<property name="driverName" value="${jdbc2.driver}" />
					<property name="url" value="${jdbc2.url}" />
					<property name="user" value="${jdbc2.username}" />
					<property name="password" value="${jdbc2.password}" />
					<property name="minCon" value="1" />
				</bean>
		</property>
		<property name="transactionManager">
			<ref bean="jotm" />
		</property>
		<property name="maxSize">
			<value>10</value>
		</property>
		<property name="user" value="${jdbc2.username}" />
		<property name="password" value="${jdbc2.password}" />
	</bean>
</beans>

 采用jotm事务的applicationContext-jotm.xml

<?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:tx="http://www.springframework.org/schema/tx"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:p="http://www.springframework.org/schema/p"
	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/context http://www.springframework.org/schema/context/spring-context-3.0.xsd 
		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
	<!-- JOTM本地实例 -->
	<bean id="jotm" class="com.easyway.ibatis.framework.jta.JotmFactoryBean" />

	<!-- JTA事务管理器 -->
	<bean id="txManager"
		class="org.springframework.transaction.jta.JtaTransactionManager">
		<property name="userTransaction" ref="jotm" />
	</bean>

	<!-- JTA事务传播特性 -->
	<tx:advice id="txAdviceJta" transaction-manager="txManager">
		<tx:attributes>
			<tx:method name="Jta*" isolation="DEFAULT" propagation="REQUIRED"
				rollback-for="Exception" />
			<tx:method name="*" read-only="true" />
		</tx:attributes>
	</tx:advice>

	<aop:config>
		<aop:advisor pointcut="execution(* com.easyway.ibatis.app.modules.service.impl..*(..))"
			advice-ref="txAdviceJta" />
	</aop:config>
</beans>

 

 

ibatis的配置如下:applicationContext-ibatis.xml

<?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:tx="http://www.springframework.org/schema/tx"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:context="http://www.springframework.org/schema/context"
    xmlns:p="http://www.springframework.org/schema/p"
	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/context http://www.springframework.org/schema/context/spring-context-3.0.xsd 
		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
    
    <bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor"  lazy-init="true" />  

	<bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" lazy-init="true">  
	    <property name="nativeJdbcExtractor">  
	        <ref local="nativeJdbcExtractor" />  
	    </property>  
	</bean>  
	
    
    <!-- Spring 提供给IBatis的SqlMap的配置 -->  
    <bean id="sqlMapClientForMySQL"
        class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
       <property name="configLocation"> 
           <value>classpath:/sql-map-config_A.xml</value>  
       </property>  
       <property name="dataSource">  
          <ref  bean="mysqlJta"/>  
       </property>  
    </bean>
	
	<!--创建SqlMapClientTemplate类  -->
	<bean id="sqlMapClientTemplateForMySQL" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
		<property name="sqlMapClient" ref="sqlMapClientForMySQL"/>
	</bean>
	
	
    	
    
    <!-- Spring 提供给IBatis的SqlMap的配置 -->  
    <bean id="sqlMapClientForOracle"
        class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
       <property name="configLocation">  
           <value>classpath:/sql-map-config_B.xml</value>  
       </property>  
       <property name="dataSource">  
          <ref  bean="oracleJta"/>  
       </property>  
    </bean>
    
    	<!--创建SqlMapClientTemplate类  -->
	<bean id="sqlMapClientTemplateForOracle" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
		<property name="sqlMapClient" ref="sqlMapClientForOracle"/>
	</bean>
	
</beans>

 

执行测试错误如下:

2013-03-25 15:50:07  - INFO  org.springframework.context.support.ClassPathXmlApplicationContext         - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1a457b6: startup date [Mon Mar 25 15:50:07 CST 2013]; root of context hierarchy

 2013-03-25 15:50:07  - INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader         - Loading XML bean definitions from class path resource [applicationContext-datasource.xml]

 2013-03-25 15:50:07  - INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader         - Loading XML bean definitions from class path resource [applicationContext-jotm.xml]

 2013-03-25 15:50:07  - INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader         - Loading XML bean definitions from class path resource [applicationContext-component.xml]

 2013-03-25 15:50:07  - INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader         - Loading XML bean definitions from class path resource [applicationContext-ibatis.xml]

 2013-03-25 15:50:08  - INFO  org.springframework.beans.factory.config.PropertyPlaceholderConfigurer         - Loading properties file from class path resource [jdbc.properties]

 2013-03-25 15:50:08  - INFO  org.springframework.beans.factory.support.DefaultListableBeanFactory         - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@172e449: defining beans [propertyConfig,mysqlJta,oracleJta,jotm,txManager,txAdviceJta,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0,tabADAO,tabBDAO,stuSrv,nativeJdbcExtractor,oracleLobHandler,sqlMapClientForMySQL,sqlMapClientTemplateForMySQL,sqlMapClientForOracle,sqlMapClientTemplateForOracle]; root of factory hierarchy

 2013-03-25 15:50:08  - INFO  org.objectweb.jotm         - CAROL initialization

 2013-03-25 15:50:08  - INFO  org.ow2.carol.util.configuration.ConfigurationRepository         - No protocols were defined for property 'carol.protocols', trying with default protocol = 'jrmp'.

 2013-03-25 15:50:08  - INFO  org.objectweb.jotm         - JOTM started with a local transaction factory

 2013-03-25 15:50:08  - INFO  org.springframework.transaction.jta.JtaTransactionManager         - Using JTA UserTransaction: org.objectweb.jotm.Current@1e2befa

 2013-03-25 15:50:08  - INFO  org.springframework.transaction.jta.JtaTransactionManager         - Using JTA TransactionManager: org.objectweb.jotm.Current@1e2befa

2013-03-25 15:50:08  - DEBUG java.sql.Connection         - {conn-100000} Connection

 2013-03-25 15:50:08  - DEBUG java.sql.Connection         - {conn-100000} Preparing Statement:                   insert into tab_a(                  id,                  name,                  address                  ) values (                  ?,                  ?,                  ?                  )                            

 2013-03-25 15:50:08  - ERROR org.enhydra.jdbc.xapool         - Error Exception in GenericPool:start java.sql.SQLException: Cannot get connection for URL jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8 : Access denied for user 'root '@'localhost' (using password: YES)

 2013-03-25 15:50:08  - ERROR org.enhydra.jdbc.xapool         - Error Exception in GenericPool:start java.sql.SQLException: Cannot get connection for URL jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8 : Access denied for user 'root '@'localhost' (using password: YES)

 2013-03-25 15:50:08  - ERROR org.enhydra.jdbc.xapool         - GenericPool:getFromPool Error Exception in GenericPool:getFromPool

 java.sql.SQLException: Cannot get connection for URL jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8 : Access denied for user 'root '@'localhost' (using password: YES)

at org.enhydra.jdbc.standard.StandardDataSource.getConnection(StandardDataSource.java:216)

at org.enhydra.jdbc.standard.StandardPooledConnection.<init>(StandardPooledConnection.java:65)

at org.enhydra.jdbc.standard.StandardXAConnection.<init>(StandardXAConnection.java:81)

at org.enhydra.jdbc.standard.StandardXADataSource.getXAConnection(StandardXADataSource.java:110)

at org.enhydra.jdbc.pool.StandardXAPoolDataSource.create(StandardXAPoolDataSource.java:159)

at org.enhydra.jdbc.pool.GenericPool.getFromPool(GenericPool.java:247)

at org.enhydra.jdbc.pool.GenericPool.checkOut(GenericPool.java:351)

at org.enhydra.jdbc.pool.StandardPoolDataSource.getConnection(StandardPoolDataSource.java:194)

at org.enhydra.jdbc.pool.StandardPoolDataSource.getConnection(StandardPoolDataSource.java:164)

at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)

at org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy$TransactionAwareInvocationHandler.invoke(TransactionAwareDataSourceProxy.java:224)

at $Proxy1.prepareStatement(Unknown Source)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at com.ibatis.common.jdbc.logging.ConnectionLogProxy.invoke(ConnectionLogProxy.java:53)

at $Proxy2.prepareStatement(Unknown Source)

at com.ibatis.sqlmap.engine.execution.SqlExecutor.prepareStatement(SqlExecutor.java:497)

at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:75)

at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.sqlExecuteUpdate(MappedStatement.java:216)

at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeUpdate(MappedStatement.java:94)

at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:393)

at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:82)

at org.springframework.orm.ibatis.SqlMapClientTemplate$8.doInSqlMapClient(SqlMapClientTemplate.java:366)

at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:200)

at org.springframework.orm.ibatis.SqlMapClientTemplate.insert(SqlMapClientTemplate.java:364)

at com.easyway.ibatis.app.modules.dao.impl.TabADAOImpl.saveTabA(TabADAOImpl.java:27)

at com.easyway.test.SpringIbatisJotmTM.main(SpringIbatisJotmTM.java:106)

java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection no connection available java.sql.SQLException: Cannot get connection for URL jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8 : Access denied for user 'root '@'localhost' (using password: YES)

at org.enhydra.jdbc.pool.StandardPoolDataSource.getConnection(StandardPoolDataSource.java:204)

at org.enhydra.jdbc.pool.StandardPoolDataSource.getConnection(StandardPoolDataSource.java:164)

at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)

at org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy$TransactionAwareInvocationHandler.invoke(TransactionAwareDataSourceProxy.java:224)

at $Proxy1.prepareStatement(Unknown Source)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at com.ibatis.common.jdbc.logging.ConnectionLogProxy.invoke(ConnectionLogProxy.java:53)

at $Proxy2.prepareStatement(Unknown Source)

at com.ibatis.sqlmap.engine.execution.SqlExecutor.prepareStatement(SqlExecutor.java:497)

at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:75)

at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.sqlExecuteUpdate(MappedStatement.java:216)

at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeUpdate(MappedStatement.java:94)

at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:393)

at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:82)

at org.springframework.orm.ibatis.SqlMapClientTemplate$8.doInSqlMapClient(SqlMapClientTemplate.java:366)

at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:200)

at org.springframework.orm.ibatis.SqlMapClientTemplate.insert(SqlMapClientTemplate.java:364)

at com.easyway.ibatis.app.modules.dao.impl.TabADAOImpl.saveTabA(TabADAOImpl.java:27)

at com.easyway.test.SpringIbatisJotmTM.main(SpringIbatisJotmTM.java:106)

2013-03-25 15:50:08  - ERROR java.sql.Connection         - Error calling Connection.prepareStatement:

 java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection exception: java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection no connection available java.sql.SQLException: Cannot get connection for URL jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8 : Access denied for user 'root '@'localhost' (using password: YES)

at org.enhydra.jdbc.pool.StandardPoolDataSource.getConnection(StandardPoolDataSource.java:213)

at org.enhydra.jdbc.pool.StandardPoolDataSource.getConnection(StandardPoolDataSource.java:164)

at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)

at org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy$TransactionAwareInvocationHandler.invoke(TransactionAwareDataSourceProxy.java:224)

at $Proxy1.prepareStatement(Unknown Source)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at com.ibatis.common.jdbc.logging.ConnectionLogProxy.invoke(ConnectionLogProxy.java:53)

at $Proxy2.prepareStatement(Unknown Source)

at com.ibatis.sqlmap.engine.execution.SqlExecutor.prepareStatement(SqlExecutor.java:497)

at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:75)

at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.sqlExecuteUpdate(MappedStatement.java:216)

at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeUpdate(MappedStatement.java:94)

at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:393)

at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:82)

at org.springframework.orm.ibatis.SqlMapClientTemplate$8.doInSqlMapClient(SqlMapClientTemplate.java:366)

at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:200)

at org.springframework.orm.ibatis.SqlMapClientTemplate.insert(SqlMapClientTemplate.java:364)

at com.easyway.ibatis.app.modules.dao.impl.TabADAOImpl.saveTabA(TabADAOImpl.java:27)

at com.easyway.test.SpringIbatisJotmTM.main(SpringIbatisJotmTM.java:106)

2013-03-25 15:50:08  - INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader         - Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]

 2013-03-25 15:50:08  - INFO  org.springframework.jdbc.support.SQLErrorCodesFactory         - SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]

 2013-03-25 15:50:08  - ERROR org.enhydra.jdbc.xapool         - GenericPool:getFromPool Error Exception in GenericPool:getFromPool

 java.sql.SQLException: Cannot get connection for URL jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8 : Access denied for user 'root '@'localhost' (using password: YES)

at org.enhydra.jdbc.standard.StandardDataSource.getConnection(StandardDataSource.java:216)

at org.enhydra.jdbc.standard.StandardPooledConnection.<init>(StandardPooledConnection.java:65)

at org.enhydra.jdbc.standard.StandardXAConnection.<init>(StandardXAConnection.java:81)

at org.enhydra.jdbc.standard.StandardXADataSource.getXAConnection(StandardXADataSource.java:110)

at org.enhydra.jdbc.pool.StandardXAPoolDataSource.create(StandardXAPoolDataSource.java:159)

at org.enhydra.jdbc.pool.GenericPool.getFromPool(GenericPool.java:247)

at org.enhydra.jdbc.pool.GenericPool.checkOut(GenericPool.java:351)

at org.enhydra.jdbc.pool.StandardPoolDataSource.getConnection(StandardPoolDataSource.java:194)

at org.enhydra.jdbc.pool.StandardPoolDataSource.getConnection(StandardPoolDataSource.java:164)

at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)

at org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy$TransactionAwareInvocationHandler.invoke(TransactionAwareDataSourceProxy.java:224)

at $Proxy1.getMetaData(Unknown Source)

at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:285)

at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:320)

at org.springframework.jdbc.support.SQLErrorCodesFactory.getErrorCodes(SQLErrorCodesFactory.java:214)

at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.setDataSource(SQLErrorCodeSQLExceptionTranslator.java:141)

at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.<init>(SQLErrorCodeSQLExceptionTranslator.java:104)

at org.springframework.jdbc.support.JdbcAccessor.getExceptionTranslator(JdbcAccessor.java:99)

at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:203)

at org.springframework.orm.ibatis.SqlMapClientTemplate.insert(SqlMapClientTemplate.java:364)

at com.easyway.ibatis.app.modules.dao.impl.TabADAOImpl.saveTabA(TabADAOImpl.java:27)

at com.easyway.test.SpringIbatisJotmTM.main(SpringIbatisJotmTM.java:106)

java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection no connection available java.sql.SQLException: Cannot get connection for URL jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8 : Access denied for user 'root '@'localhost' (using password: YES)

at org.enhydra.jdbc.pool.StandardPoolDataSource.getConnection(StandardPoolDataSource.java:204)

at org.enhydra.jdbc.pool.StandardPoolDataSource.getConnection(StandardPoolDataSource.java:164)

at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)

at org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy$TransactionAwareInvocationHandler.invoke(TransactionAwareDataSourceProxy.java:224)

at $Proxy1.getMetaData(Unknown Source)

at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:285)

at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:320)

at org.springframework.jdbc.support.SQLErrorCodesFactory.getErrorCodes(SQLErrorCodesFactory.java:214)

at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.setDataSource(SQLErrorCodeSQLExceptionTranslator.java:141)

at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.<init>(SQLErrorCodeSQLExceptionTranslator.java:104)

at org.springframework.jdbc.support.JdbcAccessor.getExceptionTranslator(JdbcAccessor.java:99)

at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:203)

at org.springframework.orm.ibatis.SqlMapClientTemplate.insert(SqlMapClientTemplate.java:364)

at com.easyway.ibatis.app.modules.dao.impl.TabADAOImpl.saveTabA(TabADAOImpl.java:27)

at com.easyway.test.SpringIbatisJotmTM.main(SpringIbatisJotmTM.java:106)

2013-03-25 15:50:08  - WARN  org.springframework.jdbc.support.SQLErrorCodesFactory         - Error while extracting database product name - falling back to empty error codes

 org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection exception: java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection no connection available java.sql.SQLException: Cannot get connection for URL jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8 : Access denied for user 'root '@'localhost' (using password: YES)

at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:296)

at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:320)

at org.springframework.jdbc.support.SQLErrorCodesFactory.getErrorCodes(SQLErrorCodesFactory.java:214)

at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.setDataSource(SQLErrorCodeSQLExceptionTranslator.java:141)

at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.<init>(SQLErrorCodeSQLExceptionTranslator.java:104)

at org.springframework.jdbc.support.JdbcAccessor.getExceptionTranslator(JdbcAccessor.java:99)

at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:203)

at org.springframework.orm.ibatis.SqlMapClientTemplate.insert(SqlMapClientTemplate.java:364)

at com.easyway.ibatis.app.modules.dao.impl.TabADAOImpl.saveTabA(TabADAOImpl.java:27)

at com.easyway.test.SpringIbatisJotmTM.main(SpringIbatisJotmTM.java:106)

Caused by: java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection exception: java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection no connection available java.sql.SQLException: Cannot get connection for URL jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8 : Access denied for user 'root '@'localhost' (using password: YES)

at org.enhydra.jdbc.pool.StandardPoolDataSource.getConnection(StandardPoolDataSource.java:213)

at org.enhydra.jdbc.pool.StandardPoolDataSource.getConnection(StandardPoolDataSource.java:164)

at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)

at org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy$TransactionAwareInvocationHandler.invoke(TransactionAwareDataSourceProxy.java:224)

at $Proxy1.getMetaData(Unknown Source)

at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:285)

... 9 more

Exception in thread "main" org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error code [0];   

--- The error occurred in sqlmap/tabA.xml.  

--- The error occurred while executing update.  

--- Check the                   insert into tab_a(                  id,                  name,                  address                  ) values (                  ?,                  ?,                  ?                  )                            .  

--- Check the SQL Statement (preparation failed).  

--- Cause: java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection exception: java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection no connection available java.sql.SQLException: Cannot get connection for URL jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8 : Access denied for user 'root '@'localhost' (using password: YES); nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:   

--- The error occurred in sqlmap/tabA.xml.  

--- The error occurred while executing update.  

--- Check the                   insert into tab_a(                  id,                  name,                  address                  ) values (                  ?,                  ?,                  ?                  )                            .  

--- Check the SQL Statement (preparation failed).  

--- Cause: java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection exception: java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection no connection available java.sql.SQLException: Cannot get connection for URL jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8 : Access denied for user 'root '@'localhost' (using password: YES)

at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)

at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)

at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)

at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:203)

at org.springframework.orm.ibatis.SqlMapClientTemplate.insert(SqlMapClientTemplate.java:364)

at com.easyway.ibatis.app.modules.dao.impl.TabADAOImpl.saveTabA(TabADAOImpl.java:27)

at com.easyway.test.SpringIbatisJotmTM.main(SpringIbatisJotmTM.java:106)

Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:   

--- The error occurred in sqlmap/tabA.xml.  

--- The error occurred while executing update.  

--- Check the                   insert into tab_a(                  id,                  name,                  address                  ) values (                  ?,                  ?,                  ?                  )                            .  

--- Check the SQL Statement (preparation failed).  

--- Cause: java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection exception: java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection no connection available java.sql.SQLException: Cannot get connection for URL jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8 : Access denied for user 'root '@'localhost' (using password: YES)

at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeUpdate(MappedStatement.java:107)

at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:393)

at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:82)

at org.springframework.orm.ibatis.SqlMapClientTemplate$8.doInSqlMapClient(SqlMapClientTemplate.java:366)

at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:200)

... 3 more

Caused by: java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection exception: java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection no connection available java.sql.SQLException: Cannot get connection for URL jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8 : Access denied for user 'root '@'localhost' (using password: YES)

at org.enhydra.jdbc.pool.StandardPoolDataSource.getConnection(StandardPoolDataSource.java:213)

at org.enhydra.jdbc.pool.StandardPoolDataSource.getConnection(StandardPoolDataSource.java:164)

at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)

at org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy$TransactionAwareInvocationHandler.invoke(TransactionAwareDataSourceProxy.java:224)

at $Proxy1.prepareStatement(Unknown Source)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at com.ibatis.common.jdbc.logging.ConnectionLogProxy.invoke(ConnectionLogProxy.java:53)

at $Proxy2.prepareStatement(Unknown Source)

at com.ibatis.sqlmap.engine.execution.SqlExecutor.prepareStatement(SqlExecutor.java:497)

at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:75)

at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.sqlExecuteUpdate(MappedStatement.java:216)

at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeUpdate(MappedStatement.java:94)

... 7 more

 

希望各位大侠指点一下!

分享到:
评论

相关推荐

    XApool连接池报空指针错误解决

    NULL 博文链接:https://fableking.iteye.com/blog/954153

    JTA 分布式事务 XAPool 1.5和1.6的所有jar包,源码包

    3. **故障恢复**:当数据库连接出现问题时,XAPool可以检测到并自动进行故障切换,确保系统的高可用性。 4. **监控和统计**:XAPool提供详细的统计信息和监控能力,帮助开发者了解连接池的运行状态,进行优化和调试...

    数据库连接池以及hibernate对各种连接池的整合

    8. **SmartPool**:模仿应用服务器对象池特性,解决连接泄漏、阻塞等问题,支持多池、自动关闭JDBC对象等。 9. **MiniConnectionPoolManager**:轻量级且无第三方依赖的JDBC数据库连接池,适用于简单场景。 10. **...

    xapool-1.5.0-src 源码下载

    《深入解析xapool-1.5.0-src:挖掘JDBC连接池的源码奥秘》 在Java开发中,数据库连接管理是一项至关重要的任务,有效地管理数据库连接可以提高系统的性能和稳定性。xapool-1.5.0-src是Enhydra项目中的一个开源JDBC...

    Java-ConnectionPools.rar_连接池

    9. **XAPool**:XAPool是GigaSpaces XAP的一部分,主要用于提供高可用性和容错性的数据库连接池。XAPool与分布式事务处理相结合,适合在分布式环境中使用。 10. **rpDatabasePool2_0**:这可能是一个特定版本的...

    xapool-1.6jar包

    xapool-1.6jar包,修复了以前版本的bug

    spring3.0+struts2.0+mybatis3.2+jta+xapool配置文件示例

    **XAPool** 是一个基于X/Open XA的JDBC连接池,提供高性能和高可用性的事务处理。在配置中,你需要定义连接池大小、超时时间、验证查询等参数,以优化数据库连接的管理。 在"studentManager"这个项目中,这些组件...

    xapool.jar

    xapool.jar............

    jotm 的 jar

    在JOTM中,XAPool jar 文件(xapool.jar)的作用是提供连接池服务,允许JOTM更有效地管理和复用数据库连接,减少创建和销毁连接的开销,提高系统性能和资源利用率。XAPool 是X/Open XA资源适配器的一个组成部分,它...

    xapool-1.4.jar

    开源XA JDBC池 com.experlog/xapool/1.4/xapool-1.4.jar

    xapool-1.6-beta.jar

    开源XA JDBC池 com.experlog/xapool/1.6-beta/xapool-1.6-beta.jar

    ActiveMQ配置Mysql8为持久化方式所需Jar包.rar

    - 这里`xaDataSourceClassName`指定了MySQL的XAPool连接池类,`url`是数据库连接地址,`user`和`password`是数据库访问凭证。 4. **所需Jar包**: - 为了使ActiveMQ能与MySQL 8通信,你需要在ActiveMQ的`lib`目录...

    JOTM开发所需jar包

    5. xapool.jar:这通常是一个连接池库,例如XAPool,用于高效管理数据库连接。 6. jotm-1.4.3.jar:与上面的jotm.jar类似,是JOTM的另一个版本,版本号为1.4.3。 7. jonas_timer-1.4.3.jar:可能与Jonas服务器(一...

    spring+druid+AtomikosDataSource实现多数据源切换及分布式事务控制

    Druid是一个优秀的数据库连接池组件,而AtomikosDataSource则是处理分布式事务的重要工具。下面我们将详细探讨如何利用Spring、Druid和AtomikosDataSource来实现这些功能。 1. **Spring框架与数据源** Spring提供...

    Spring分布式事务实现

    `xapool.jar`是XAPool,它是Apache软件基金会的一个项目,提供了一个高效的JDBC连接池,对JOTM这样的事务管理器非常有用。 `spring.jar`包含了Spring框架的核心类,其中包括了Spring的事务管理组件。`aspectjweaver...

    分布式事务操作之Spring+JTA+mybatis源码

    - **XAPool 或其他连接池**:为了支持JTA,你需要一个JTA兼容的数据源,如XAPool,它可以提供JTA连接池。 - **Atomikos、Bitronix等JTA实现**:这些第三方库实现了JTA规范,可以用来管理分布式事务。 6. **配置...

    SSH开发所需的jar包4

    9. **xapool.jar**:这个库通常用于数据库连接池,如XAPool,它是Apache的Jakarta Commons Pool的特定实现,用于管理数据库连接的分配和回收。 10. **struts2-spring-plugin-2.1.8.1.jar**:这是Struts2的Spring...

    简易搭建ssh 框架

    xapool.jar可能包含的是XAPool,这是一个连接池库,用于提高数据库连接的复用率,减少创建和关闭连接的开销。 接下来是Struts框架,它是基于MVC(模型-视图-控制器)设计模式的Java Web开发框架。Struts负责处理...

    Spring中的全局(分布式、容器)事务的项目,可以脱离JBOSS的存在

    通过这个项目,开发者可以学习到如何在非JBoss环境下,构建可扩展且健壮的分布式应用程序,这对于那些希望避免依赖特定应用服务器的项目来说,具有很高的参考价值。 总的来说,Spring的全局事务管理能力配合...

    spring+mybatis+atomikos配置文件及相关包.rar

    - Atomikos提供了XAPool,这是一个连接池实现,支持JTA。需要配置Atomikos的数据源,如`com.atomikos.jdbc.AtomikosDataSourceBean`,并设置相应的JDBC连接信息。 5. **Spring的事务管理** - 使用`@Transactional...

Global site tag (gtag.js) - Google Analytics