mysql数据库的unread result found异常

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/u011881908/article/details/53035401
今天在python中做了一下对mysql的操作,程序执行时报了一个unread result found的异常。调试了一下,发现问题出在数据库进行查询操作的时候,不过一直搞不清楚具体原因。baidu了一下,原来是一个数据库的查询操作没有进行fetchxxx()。原来,不管针对数据库的查询有没有返回结果,必须要进行fetchxxx(),否则进行下一个其他的insert、create等待操作的时候就会报unread result found的异常了。
特地记录一下,备忘。
展开阅读全文

异常:/hibernate.cfg.xml not found

04-10

是在ssh整合时发生的,ssh是手动搭建的,后来因为在hibernate反向工程的时候找不到项目名,所以又直接右键工程--> MyEclipse --> Add Hibernate 。[color=#FF0000]我明明是将applicationContext.xml和hibernate.cfg.xml合并了 为什么它还要去找hibernate[/color]rn 写了一个简单的登录程序 在运行到调用dao的时候 就抛了异常 下面是我的配置文件rnrnrnweb.xmlrn[code=html]rnrnrn rn rn index.jsprn rn rn rn contextConfigLocation rn /WEB-INF/classes/applicationContext.xmlrn rn rn org.springframework.web.context.ContextLoaderListenerrn rn rn rn struts2rn rn org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilterrn rn rn rn struts2rn *.actionrn rnrn[/code]rnrnrnsturts.xmlrn[code=html]rnrnrnrn rn rn /register.jsprn /index.jsprn rn rnrn[/code]rnrnrnapplicationContext.xmlrn[code=html]rnrnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn org.hibernate.dialect.MySQLDialectrn rn rn rn rnrn[/code]rnrnrn异常信息rn[code=java]rn%%%% Error Creating SessionFactory %%%%rnorg.hibernate.HibernateException: /hibernate.cfg.xml not foundrn at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:170)rn at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:2146)rn at org.hibernate.cfg.Configuration.configure(Configuration.java:2127)rn at com.mulan.dao.HibernateSessionFactory.(HibernateSessionFactory.java:30)rn at com.mulan.dao.BaseHibernateDAO.getSession(BaseHibernateDAO.java:13)rn at com.mulan.dao.TreasureDAO.findById(TreasureDAO.java:68)rn at com.mulan.struts.action.Bacis.login(Bacis.java:102)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:450)rn at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:289)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:252)rn at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)rn at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:249)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:249)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)rn at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:546)rn at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)rn at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)rn at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)rn at java.lang.Thread.run(Thread.java:619)rn[/code]rnrn另外 HibernateSessionFactory.java 文件已经被我修改了rn[code=java]rn//以前是rnprivate static String CONFIG_FILE_LOCATION = "/hibernate.cfg.xml";rn//我改成了rnprivate static String CONFIG_FILE_LOCATION = "/applicationContext.xml";rn[/code]rnrn真不知道是哪里还在找 hibernate.cfg.xmlrnrn各位高手 .. 论坛

An Authentication object was not found in the SecurityContex 异常

08-09

最近正在使用spring security做函数安全性控制,如果通过访问页面的方式,我查看在调用方法的时候能够顺利进入@PreAuthorize中指定的验证函数返回 true or false 以判断是否具备访问权限。rnrn可是目前我使用Spring 的 @Scheduled 进行一些定期的操作,也就是说在没有session的情况下,没有用户触发系统自己调用方法,可是当系统后台调用这个@Scheduled方法的时候,而在这个方法内部调用了一些通过@PreAuthorize控制了访问权限的方法,这样一来就出现如下异常,无法验证是否具备访问权限。很恼人。。rnrn异常代码如下rnrnrn[code=Java]org.springframework.security.authentication.AuthenticationCredentialsNotFoundException: An Authentication object was not found in the SecurityContextrn at org.springframework.security.access.intercept.AbstractSecurityInterceptor.credentialsNotFound(AbstractSecurityInterceptor.java:325)rn at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:196)rn at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:64)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)rn at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)rn at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)rn at $Proxy40.refreshGlobalCacheStrategyMetrics(Unknown Source)rn at org.sly.main.server.service.system.scheduling.MaintenanceServiceImpl.runRecreateStrategyMetricsCache(MaintenanceServiceImpl.java:85)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)rn at org.springframework.aop.interceptor.AsyncExecutionInterceptor$1.call(AsyncExecutionInterceptor.java:80)rn at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)rn at java.util.concurrent.FutureTask.run(FutureTask.java:138)rn at java.lang.Thread.run(Thread.java:662)[/code]rnrnrnrnrnrn我在网上找了很久,在spring官网也看到这个问题,可是没有给出具体解决方法rnrn[url=http://static.springsource.org/spring-security/site/faq.html#auth-exception-credentials-not-found]http://static.springsource.org/spring-security/site/faq.html#auth-exception-credentials-not-found[/url] rnrn摘取了相关的描述如下:rnrn1.5. I get an exception with the message "An Authentication object was not found in the SecurityContext". What's wrong?rnrnThis is a another debug level message which occurs the first time an anonymous user attempts to access a protected resource, but when you do not have an [b]AnonymousAuthenticationFilter[/b] in your filter chain configuration.rnrn DEBUG [ExceptionTranslationFilter] - Authentication exception occurred; redirecting to authentication entry pointrn org.springframework.security.AuthenticationCredentialsNotFoundException:rn An Authentication object was not found in the SecurityContextrn at org.springframework.security.intercept.AbstractSecurityInterceptor.credentialsNotFound(AbstractSecurityInterceptor.java:342)rn at org.springframework.security.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:254)rnrnrn而在另一个页面给出了配置 [b]AnonymousAuthenticationFilter[/b]rn[url=http://static.springsource.org/spring-security/site/docs/3.0.x/reference/anonymous.html]http://static.springsource.org/spring-security/site/docs/3.0.x/reference/anonymous.html[/url]rnrn说是要这么配置rn[code=XML]rnrn rn rnrnrnrn rnrn[/code]rnrnrnrnrn于是乎,我就在我的 application-security.xml 中做了如下配置,但是没有任何效果rnrn[code=XML]rn rn rn rn rn rn rn rn rn rn rn rn rnrn rn rn rn[/code] 论坛

Mysql数据库出现如下异常

08-02

java.net.SocketException: Software caused connection abort: socket write errorrn at java.net.SocketOutputStream.socketWrite0(Native Method)rn at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)rn at java.net.SocketOutputStream.write(SocketOutputStream.java:136)rn at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:66)rn at java.io.BufferedOutputStream.write(BufferedOutputStream.java:110)rn at java.io.DataOutputStream.write(DataOutputStream.java:85)rn at org.gjt.mm.mysql.MysqlIO.send(MysqlIO.java)rn at org.gjt.mm.mysql.MysqlIO.sendCommand(MysqlIO.java)rn at org.gjt.mm.mysql.MysqlIO.sqlQueryDirect(MysqlIO.java)rn at org.gjt.mm.mysql.MysqlIO.sqlQuery(MysqlIO.java)rn at org.gjt.mm.mysql.Connection.execSQL(Connection.java)rn at org.gjt.mm.mysql.Connection.execSQL(Connection.java)rn at org.gjt.mm.mysql.Statement.executeQuery(Statement.java)rn at org.gjt.mm.mysql.jdbc2.Statement.executeQuery(Statement.java:78)rn at com.ocamar.nms.TrapThread.trapv1process(TrapThread.java:200)rn at com.ocamar.nms.TrapThread$1.run(TrapThread.java:66)rn at java.lang.Thread.run(Thread.java:534)rnjava.sql.SQLException: Communication link failure: java.net.SocketExceptionrn at org.gjt.mm.mysql.MysqlIO.sendCommand(MysqlIO.java)rn at org.gjt.mm.mysql.MysqlIO.sqlQueryDirect(MysqlIO.java)rn at org.gjt.mm.mysql.MysqlIO.sqlQuery(MysqlIO.java)rn at org.gjt.mm.mysql.Connection.execSQL(Connection.java)rn at org.gjt.mm.mysql.Connection.execSQL(Connection.java)rn at org.gjt.mm.mysql.Statement.executeQuery(Statement.java)rn at org.gjt.mm.mysql.jdbc2.Statement.executeQuery(Statement.java:78)rn at com.ocamar.nms.TrapThread.trapv1process(TrapThread.java:200)rn at com.ocamar.nms.TrapThread$1.run(TrapThread.java:66)rn at java.lang.Thread.run(Thread.java:534)rnjava.net.SocketException: Software caused connection abort: socket write errorrn at java.net.SocketOutputStream.socketWrite0(Native Method)rn at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)rn at java.net.SocketOutputStream.write(SocketOutputStream.java:136)rn at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:66)rn at java.io.BufferedOutputStream.write(BufferedOutputStream.java:110)rn at java.io.DataOutputStream.write(DataOutputStream.java:85)rn at org.gjt.mm.mysql.MysqlIO.send(MysqlIO.java)rn at org.gjt.mm.mysql.MysqlIO.sendCommand(MysqlIO.java)rn at org.gjt.mm.mysql.MysqlIO.sqlQueryDirect(MysqlIO.java)rn at org.gjt.mm.mysql.MysqlIO.sqlQuery(MysqlIO.java)rn at org.gjt.mm.mysql.Connection.execSQL(Connection.java)rn at org.gjt.mm.mysql.Connection.execSQL(Connection.java)rn at org.gjt.mm.mysql.Statement.execute(Statement.java)rn at org.gjt.mm.mysql.jdbc2.Statement.execute(Statement.java:114)rn at com.ocamar.nms.TrapThread.trapv1process(TrapThread.java:286)rn at com.ocamar.nms.TrapThread$1.run(TrapThread.java:66)rn at java.lang.Thread.run(Thread.java:534)rnjava.sql.SQLException: Communication link failure: java.net.SocketExceptionrn at org.gjt.mm.mysql.MysqlIO.sendCommand(MysqlIO.java)rn at org.gjt.mm.mysql.MysqlIO.sqlQueryDirect(MysqlIO.java)rn at org.gjt.mm.mysql.MysqlIO.sqlQuery(MysqlIO.java)rn at org.gjt.mm.mysql.Connection.execSQL(Connection.java)rn at org.gjt.mm.mysql.Connection.execSQL(Connection.java)rn at org.gjt.mm.mysql.Statement.execute(Statement.java)rn at org.gjt.mm.mysql.jdbc2.Statement.execute(Statement.java:114)rn at com.ocamar.nms.TrapThread.trapv1process(TrapThread.java:286)rn at com.ocamar.nms.TrapThread$1.run(TrapThread.java:66)rn at java.lang.Thread.run(Thread.java:534)rnrnrnbtw:数据库连接是通过自己的连接池返回的,可能在查询时出现如上的异常,google里也没找到什么办法 论坛

连接MYSQL数据库异常

01-14

这是我从家里拿来的可用的项目,在家里是可以运行的。rn今天放在别的机器上,同样配置就出现了如下异常:rn** BEGIN NESTED EXCEPTION ** rnrnjava.net.SocketExceptionrnMESSAGE: java.net.ConnectException: Connection refused: connectrnrnSTACKTRACE:rnrnjava.net.SocketException: java.net.ConnectException: Connection refused: connectrn at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:156)rn at com.mysql.jdbc.MysqlIO.(MysqlIO.java:283)rn at com.mysql.jdbc.Connection.createNewIO(Connection.java:2541)rn at com.mysql.jdbc.Connection.(Connection.java:1474)rn at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:264)rn at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:135)rn at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)rn at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)rn at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)rn at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)rn at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)rn at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)rn at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)rnrnrn** END NESTED EXCEPTION **rnrn补充说明:rn不是防火墙,端口等问题。因为我写一个小测试类是可以连接数据库的。rn应该是配置文件的问题。我把配置文件也发上来rnrnrn rn rn rn rn rn rn rn rn 论坛

服务器 mysql数据库异常

02-16

查看服务器的log日志的时候,发现服务器中经常报一些如下的错误: rn[code="java"]rn2009-02-06 08:22:20,588 INFO [cn.legend.myznt.util.SystemExceptionHandler] - 出现异常 rnorg.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.TransactionException: JDBC begin failed: rnCaused by: rnorg.hibernate.TransactionException: JDBC begin failed: rn at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:68) rn at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1290) rn at org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:510) rn at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:350) rn at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:262) rn at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101) rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) rn at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:629) rn at cn.qdrk.strive.dao.hibernate.UserDaoHibernate$$EnhancerByCGLIB$$10afb0ec.queryAccount() rn at cn.qdrk.strive.struts.action.LoginAction.execute(LoginAction.java:44) rn at org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:110) rn at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58) rn at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67) rn at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51) rn at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) rn at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304) rn at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) rn at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283) rn at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) rn at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462) rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) rn at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96) rn at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75) rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) rn at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198) rn at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75) rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263) rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584) rn at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) rn at java.lang.Thread.run(Unknown Source) rnCaused by: com.mysql.jdbc.CommunicationsException: Communications link failure rn rnLast packet sent to the server was 120 ms ago. rn at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1070) rn at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2985) rn at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2871) rn at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3414) rn at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) rn at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) rn at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2536) rn at com.mysql.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:4874) rn at org.apache.tomcat.dbcp.dbcp.DelegatingConnection.setAutoCommit(DelegatingConnection.java:331) rn at org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.setAutoCommit(PoolingDataSource.java:317) rn at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:63) rn ... 41 more rnCaused by: java.net.SocketException: Software caused connection abort: recv failed rn at java.net.SocketInputStream.socketRead0(Native Method) rn at java.net.SocketInputStream.read(Unknown Source) rn at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:113) rn at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:160) rn at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:188) rn at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2428) rn at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2882) rn ... 50 more rnrn2009-02-06 08:22:20,588 INFO [cn.legend.myznt.util.SystemExceptionHandler] - 出现异常rnorg.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.TransactionException: JDBC begin failed: rnCaused by: rnorg.hibernate.TransactionException: JDBC begin failed: rn at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:68)rn at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1290)rn at org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:510)rn at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:350)rn at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:262)rn at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)rn at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:629)rn at cn.qdrk.strive.dao.hibernate.UserDaoHibernate$$EnhancerByCGLIB$$10afb0ec.queryAccount()rn at cn.qdrk.strive.struts.action.LoginAction.execute(LoginAction.java:44)rn at org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:110)rn at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)rn at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)rn at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)rn at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)rn at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)rn at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)rn at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)rn at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)rn at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)rn at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)rn at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)rn at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)rn at java.lang.Thread.run(Unknown Source)rnCaused by: com.mysql.jdbc.CommunicationsException: Communications link failurernrnLast packet sent to the server was 120 ms ago.rn at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1070)rn at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2985)rn at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2871)rn at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3414)rn at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936)rn at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)rn at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2536)rn at com.mysql.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:4874)rn at org.apache.tomcat.dbcp.dbcp.DelegatingConnection.setAutoCommit(DelegatingConnection.java:331)rn at org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.setAutoCommit(PoolingDataSource.java:317)rn at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:63)rn ... 41 morernCaused by: java.net.SocketException: Software caused connection abort: recv failedrn at java.net.SocketInputStream.socketRead0(Native Method)rn at java.net.SocketInputStream.read(Unknown Source)rn at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:113)rn at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:160)rn at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:188)rn at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2428)rn at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2882)rn ... 50 morern[/code]rn感觉数据库好像有时没连上,但是过一会好像就好了,我的tomcat配置的链接池如下: rn[code="java"]rn rnrnrn[/code]rnapplicationContext.xml中配置如下: rn[code="java"]rn rn rn rn rn rn rn rnrnrn rn rn rn rn rn rn[/code]rn是由于MySQL对于超过8小时的连接就会强行关闭,而数据库连接池并不知道,仍然持有失效的连接,当从连接池中取出并使用这种连接的时候就会出错 ,这个该怎么改呢?万分感谢! 问答

JAVA连接Mysql数据库异常

11-29

import java.sql.*;rnpublic class DB rn public static void main(String [] args)// throws SQLExceptionrn rn rn String driver="com.mysql.jdbc.Driver";rn String url="jdbc:mysql://localhost:3306/exmaple";rn String user="root";rn String password="123";rn rn Connection conn=null;rn Statement stat=null;rn ResultSet rs=null;rn rn String sql1="INSERT INTO grade(course,s_num,grade)VALUES('english',3,'32')";rn String sql2="UPDATA grade SET course='1111' WHERE id=1";rn String sql3="SELECT * FROM grade";rn rn tryrn rn Class.forName(driver);rn conn=DriverManager.getConnection(url,user,password);rn System.out.println("连接数据库成功");rn stat=conn.createStatement();rn System.out.println("连接数据库成功");rn rs=stat.executeQuery(sql1);rn System.out.println("连接数据库成功");rn while(rs.next())rn rn int id=rs.getInt("id");rn String course=rs.getString("course");rn int s_num=rs.getInt("s_num");rn String grade=rs.getString("grade");rn System.out.println(id+" "+course+" "+s_num+" "+grade);rn rn rn int i=stat.executeUpdate(sql2);rn if(i!=0)rn rn System.out.println("插入数据成功!");rn rn rn int j=stat.executeUpdate(sql3);rn if(j!=0)rn rn System.out.println("更新成功");rn rn rn catch(ClassNotFoundException e)rn rn System.out.print("没有找到数据库驱动");rn rn rn catch(SQLException e)rn rn System.out.print("连接数据库服务器异常");rn rn finallyrn rn if(rs!=null)rn rn tryrn rn rs.close();rn rs=null;rn rn catch(Exception e)rn rn e.printStackTrace();rn rn rn rnrn if(stat!=null)rn rn tryrn rn stat.close();rn stat=null;rn rn catch(Exception e)rn rn e.printStackTrace();rn rn rn rnrn if(conn!=null)rn rn tryrn rn conn.close();rn conn=null;rn rn catch(Exception e)rn rn e.printStackTrace();rn rn rn rn rnrnrnrn[color=#FF0000]运行的结果是:rn连接数据库成功rn连接数据库成功rn连接数据库服务器异常[/color]rnrnrn那即是这条语句出错rs=stat.executeQuery(sql1);请问什么问题呢?sql1语句我在数据库里执行过是可以的rn 论坛

jsp连接mysql数据库异常

01-29

使用TOMCAT5.5连接Mysql数据库,使用的是mysql-connector-java-5.0.4-bin驱动连接。rn把驱动放到了G:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib文件夹下,并且在系统变量里已经定义。rn写了一段测试程序,如下:rn<%@ page contentType="text/html;charset=gb2312" language="java" import="java.sql.*"%> rnrnrnrn<% rnString url = "jdbc:mysql://localhost:3306/test?user=root&password=123";rnClass.forName("com.mysql.jdbc.Driver").newInstance();rnConnection conn = DriverManager.getConnection(url);rnStatement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,rnResultSet.CONCUR_UPDATABLE);rnout.print("connect succeed");rn%> rnrnrn运行http://localhost:8080/test.jsp。报出如下错误:rnexception rnorg.apache.jasper.JasperException: com.mysql.jdbc.Driverrn org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rnrnrnroot cause rnjavax.servlet.ServletException: com.mysql.jdbc.Driverrn org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)rn org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)rn org.apache.jsp.xp_jsp._jspService(xp_jsp.java:62)rn org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rnrnrnroot cause rnjava.lang.ClassNotFoundException: com.mysql.jdbc.Driverrn org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1362)rn org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1208)rn org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:125)rn org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:63)rn java.lang.ClassLoader.loadClassInternal(Unknown Source)rn java.lang.Class.forName0(Native Method)rn java.lang.Class.forName(Unknown Source)rn org.apache.jsp.xp_jsp._jspService(xp_jsp.java:49)rn org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rnrn万分紧急 跪求达人解惑 论坛

没有更多推荐了,返回首页