- 浏览: 126594 次
- 性别:
- 来自: 福州
文章分类
最新评论
-
JavaEEdyc:
http://m.qianka.com/shoutu?u=21 ...
关于anroid设置webview背景方法探讨 -
JavaEEdyc:
http://m.qianka.com/shoutu?u=21 ...
android中的webview 加载html,并可以实现java调用js -
JavaEEdyc:
http://m.qianka.com/shoutu?u=21 ...
android ScrollView 与listView共存冲突问题解决方法(附图) -
zhangyang5023637:
讲的挺明白的。
android中的webview 加载html,并可以实现java调用js -
JavaEEdyc:
android中的webview 加载html,并可以实现ja ...
关于anroid设置webview背景方法探讨
java.sql.SQLException: Connections could not be acquired from the underlying da
- 博客分类:
- Spring学习
- Hibernate 学习
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: Cannot open connection; uncategorized SQLException for SQL [???]; SQL state [null]; error code [0]; Connections could not be acquired from the underlying database!; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database! 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.hibernate3.HibernateAccessor.convertJdbcAccessException(HibernateAccessor.java:424) at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:410) at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411) at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374) at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:683) at com.funo.daoImp.UpdateLogInfoDaoImp.saveActivityLog(UpdateLogInfoDaoImp.java:51) 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 org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:108) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at $Proxy0.saveActivityLog(Unknown Source) at com.funo.serviceImp.UpdateLogInfoServiceImp.saveActivityLog(UpdateLogInfoServiceImp.java:65) at com.funo.servlet.GetLogInfoServlet.doPost(GetLogInfoServlet.java:101) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:662) Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database! at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:529) at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128) at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:81) at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446) at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167) at org.hibernate.jdbc.AbstractBatcher.prepareSelectStatement(AbstractBatcher.java:145) at org.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:96) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:122) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210) at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195) at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93) at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:563) at org.hibernate.impl.SessionImpl.save(SessionImpl.java:551) at org.hibernate.impl.SessionImpl.save(SessionImpl.java:547) at org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:686) at org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:1) at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406) ... 32 more Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source. at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1319) at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557) at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:477) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:525) ... 50 more 配置好了后,进行几次操作是成功的,但是有时候操作几次后就会报上述错误。但是重新启动tomcat后仍是可以操作,也是会重复上面那个异常,可以操作,但是操作几次后仍会出错! 贴下hibernamte配置和spring配置; spring: 。。。。。。。。。。。。。 <?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" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="oracle.jdbc.driver.OracleDriver" /> <property name="jdbcUrl" value="jdbc:oracle:thin:@localhost:1521:orcl" /> <property name="user" value="scott" /> <property name="password" value="12345" /> <property name="minPoolSize" value="10" /> <property name="maxPoolSize" value="20" /> <property name="maxIdleTime" value="1800" /> <property name="acquireIncrement" value="2" /> <property name="maxStatements" value="0" /> <property name="initialPoolSize" value="15" /> <property name="idleConnectionTestPeriod" value="1800" /> <property name="acquireRetryAttempts" value="30" /> <property name="testConnectionOnCheckout" value="false" /> <property name="acquireRetryDelay" value="100"></property> <property name="breakAfterAcquireFailure" value="false"></property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="configLocation" value="classpath:/hibernate.cfg.xml"> </property> <property name="dataSource"> <ref bean="dataSource" /> </property> </bean> <bean id="logDaoImp" class="com.funo.daoImp.UpdateLogInfoDaoImp" > <property name="sessionFactory" ref="sessionFactory"></property> </bean> <bean id="registProductImp" class="com.funo.daoImp.RegistProductDaoImp" > <property name="sessionFactory" ref="sessionFactory"></property> </bean> <bean id="showLog" class="com.funo.daoImp.ShowLogDaoImp" > <property name="sessionFactory" ref="sessionFactory"></property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="update*" propagation="REQUIRED"></tx:method> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="daoPointcut" expression="execution(* com.funo.dao.Update*.*(..))"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="daoPointcut"/> </aop:config> </beans> 。。。。。。。。。。。 hibernate: 。。。。。。。。。。。。。。 <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <!-- Generated by MyEclipse Hibernate Tools. --> <hibernate-configuration> <session-factory> <!-- <property name="connection.url"> jdbc:oracle:thin:@localhost:1521:orcl </property> <property name="connection.username">scott</property> <property name="connection.password">12345</property> <property name="connection.driver_class"> oracle.jdbc.driver.OracleDriver </property> <property name="myeclipse.connection.profile"> oracle.jdbc.OracleDriver </property> --> <property name="show_sql">true</property> <property name="format_sql">true</property> <property name="hibernate.dialect"> org.hibernate.dialect.OracleDialect </property> <property name="hibernate.connection.provider_class">C3p0ConnectionProvider</property> <mapping resource="com/funo/entity/OperateLog.hbm.xml" /> <mapping resource="com/funo/entity/ProductTable.hbm.xml" /> <mapping resource="com/funo/entity/AccessLog.hbm.xml" /> <mapping resource="com/funo/entity/ActivityBase.hbm.xml" /> <mapping resource="com/funo/entity/ErrorLog.hbm.xml" /> </session-factory> </hibernate-configuration> 我初步怀疑是c3p0数据库连接池没配好!希望高手可以看下! 今天查询一些代码和资料后,写出了一种解决方案:到现在为止还没有出现错误,贴出来和大家分享下: 主要是在hibernate中配置下: 当然在整合spring后,hibernate的配置在applicationContext.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" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="oracle.jdbc.driver.OracleDriver" /> <property name="jdbcUrl" value="jdbc:oracle:thin:@localhost:1521:orcl" /> <property name="user" value="scott" /> <property name="password" value="12345" /> <!-- <property name="minPoolSize" value="5" /> <property name="maxPoolSize" value="20" /> <property name="acquireIncrement" value="2" /> <property name="maxStatements" value="100" /> <property name="initialPoolSize" value="15" /> <property name="acquireRetryAttempts" value="30" /> <property name="testConnectionOnCheckout" value="false" /> <property name="acquireRetryDelay" value="100"></property> <property name="breakAfterAcquireFailure" value="false"></property> <property name="idleConnectionTestPeriod" value="10800" /> <property name="maxIdleTime" value="21600" /> --> <!-- <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" /> --> <property name="minPoolSize"> <value>1</value> </property> <property name="maxPoolSize"> <value>20</value> </property> <property name="maxIdleTime"> <value>1800</value> </property> <property name="acquireIncrement"> <value>2</value> </property> <property name="maxStatements"> <value>0</value> </property> <property name="initialPoolSize"> <value>2</value> </property> <property name="idleConnectionTestPeriod"> <value>1800</value> </property> <property name="acquireRetryAttempts"> <value>30</value> </property> <property name="breakAfterAcquireFailure"> <value>true</value> </property> <property name="testConnectionOnCheckout"> <value>false</value> </property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="configLocation" value="classpath:/hibernate.cfg.xml"> </property> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.generate_statistics">true</prop> <prop key="hibernate.connection.release_mode">auto</prop> <prop key="hibernate.autoReconnect">true</prop> <prop key="hibernate.cglib.use_reflection_optimizer">true</prop> </props> </property> </bean> <bean id="logDaoImp" class="com.funo.daoImp.UpdateLogInfoDaoImp"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <bean id="registProductImp" class="com.funo.daoImp.RegistProductDaoImp"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <bean id="showLog" class="com.funo.daoImp.ShowLogDaoImp"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="save*" propagation="REQUIRED"></tx:method> <tx:method name="check*" propagation="REQUIRED"></tx:method> <tx:method name="get*" propagation="REQUIRED"></tx:method> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="daoPointcut" expression="execution(* com.funo.dao.*.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="daoPointcut" /> </aop:config> </beans>
hibernate 详细配置参考:http://m.cnblogs.com/48210/1493274.html
相关推荐
在Java编程中,`java.sql.SQLException: 结果集已耗尽` 是一个常见的错误提示,通常出现在处理数据库查询结果集时。这个异常表明程序试图访问已经没有数据的结果集中下一行,即所有行已经被遍历完,尝试访问超出范围...
java.sql.SQLException: 不支持的字符集 (在类路径中添加 orai18n.jar): ZHS16GBK ……
标题中的“Caused by: java.sql.SQLException: JZ0SJ: 没有在此数据库中发现元数据存取器信息。 请按 jConnect 文档中所述安装”是一个典型的错误信息,表明在尝试使用Java数据库连接(JDBC)驱动程序访问数据库时...
在oracle里面运行一下,解决Exception java.sql.SQLException ORA-00600 内部错误代码
java.sql.SQLException: null, message from server: “Host ‘223.72.41.7’ is not allowed to connect to this MySQL server” 客户端访问时报错: 解决方法: 1,登陆服务器 mysql> use mysql; //用mysql ...
它实现了Java Database Connectivity (JDBC) API,使得开发者可以使用Java语言来操作Oracle数据库,执行SQL语句,进行数据查询、插入、更新和删除等操作。Oracle JDBC驱动分为不同版本,包括 Thin、OCI、JDBC-ODBC ...
Q: I am working with ... I am using updateBinaryStream method of resultset to update the BLOB field but it is failing after giving following exception java.sql.SQLException: Internal Error: Unable to
在Oracle数据库操作中,我们经常会遇到与`java.sql.SQLException`相关的异常。这个异常通常是Java应用程序在尝试与Oracle数据库进行交互时出现的问题。本篇将详细探讨`java.sql.SQLException`的各种常见类型及其解决...
import java.sql.SQLException; ``` 3. **注册驱动**:在使用MySQL驱动前,需要通过`Class.forName()`方法注册驱动。尽管在较新的JDBC版本中这个步骤可以省略,但为了兼容性,很多示例代码仍然包含它: ```java ...
主要给大家介绍了关于MySQL存储表情时报错:java.sql.SQLException: Incorrect string value: 'xF0x9Fx92xA9x0Dx0A...'的解决方法,文中通过示例代码介绍的非常详细,需要的朋友可以参考借鉴,下面来一起看看吧。
本文主要介绍了关于MySQL存储表情报错:java.sql.SQLException: Incorrect string value: ‘\xF0\x9F\x92\xA9\x0D\x0A…’的相关解决方法,分享出供大家参考学习,下面话不多说了,来一起看看详细的介绍: ...
当你遇到"java.sql.SQLException: No suitable driver"这样的错误时,通常意味着你的Java环境无法找到匹配的数据库驱动。这个问题的解决方法是确保已经正确地引入了MySQL JDBC驱动(也称为Connector/J)。 MySQL ...
Unknown column 'fillMen' in 'field list' java.sql.SQLException: Operation not ...java.sql.SQLException: QueryRunner requires a DataSource to be invoked in this way, or a Connection should be passed in
当你尝试连接到MySQL数据库时,可能会遇到一个特定的异常:“java.sql.SQLException: The server time zone value ‘?й???????’ is unrecognized or represents more than one time zone”。这个错误表明服务器...
绝对好用的9i驱动包+10g驱动包 解决java.sql.SQLException: 不支持的特性 解决oracle.jdbc.driver.OracleDatabaseMetaData.supportsGetGeneratedKeys()Z异常 等等
问题是这样的…我在VS2008直接运行打开网页,可以连接... 异常详细信息: System.Data.SqlClient.SqlException: 无法打开登录所请求的数据库 “TakeClass”。登录失败。 用户 ‘2D2727E2578F446\ASPNET’ 登录失败。
标题中的问题“Cause: java.sql.SQLException: The server time zone value”是Java开发者在使用IDEA(IntelliJ IDEA)进行数据库连接时常见的错误提示。这个错误通常发生在尝试连接到MySQL等SQL数据库时,由于...