如何解决此异常org.hibernate.exception.JDBCConnectionException

时间:2014-05-24 03:02:01

标签: java hibernate jpa jdbc connection

org hibernate exception JDBCConnectionException: Cannot open connection
    org hibernate exception SQLStateConverter convert(SQLStateConverter java:74)
    org hibernate exception JDBCExceptionHelper convert(JDBCExceptionHelper java:43)
    org hibernate exception JDBCExceptionHelper convert(JDBCExceptionHelper java:29)
    org hibernate jdbc ConnectionManager openConnection(ConnectionManager java:426)
    org hibernate jdbc ConnectionManager getConnection(ConnectionManager java:144)
    org hibernate jdbc JDBCContext connection(JDBCContext java:119)
    org hibernate transaction JDBCTransaction begin(JDBCTransaction java:57)
    org hibernate impl SessionImpl beginTransaction(SessionImpl java:1326)
    sun reflect GeneratedMethodAccessor409 invoke(Unknown Source)
    sun reflect DelegatingMethodAccessorImpl invoke(DelegatingMethodAccessorImpl java:25)
    java lang reflect Method invoke(Method java:597)
    org hibernate context ThreadLocalSessionContext$TransactionProtectionWrapper invoke(ThreadLocalSessionContext java:301)
    $Proxy13 beginTransaction(Unknown Source)
    asiit db UserOperation listn(UserOperation java:71)
    asiit action Login execute(Login java:40)
    sun reflect NativeMethodAccessorImpl invoke0(Native Method)
    sun reflect NativeMethodAccessorImpl invoke(NativeMethodAccessorImpl java:39)
    sun reflect DelegatingMethodAccessorImpl invoke(DelegatingMethodAccessorImpl java:25)
    java lang reflect Method invoke(Method java:597)
    com opensymphony xwork2 DefaultActionInvocation invokeAction(DefaultActionInvocation java:441)
    com opensymphony xwork2 DefaultActionInvocation invokeActionOnly(DefaultActionInvocation java:280)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:243)
    com opensymphony xwork2 interceptor DefaultWorkflowInterceptor doIntercept(DefaultWorkflowInterceptor java:165)
    com opensymphony xwork2 interceptor MethodFilterInterceptor intercept(MethodFilterInterceptor java:87)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 validator ValidationInterceptor doIntercept(ValidationInterceptor java:252)
    org apache struts2 interceptor validation AnnotationValidationInterceptor doIntercept(AnnotationValidationInterceptor java:68)
    com opensymphony xwork2 interceptor MethodFilterInterceptor intercept(MethodFilterInterceptor java:87)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor ConversionErrorInterceptor intercept(ConversionErrorInterceptor java:122)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor ParametersInterceptor doIntercept(ParametersInterceptor java:195)
    com opensymphony xwork2 interceptor MethodFilterInterceptor intercept(MethodFilterInterceptor java:87)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor ParametersInterceptor doIntercept(ParametersInterceptor java:195)
    com opensymphony xwork2 interceptor MethodFilterInterceptor intercept(MethodFilterInterceptor java:87)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor StaticParametersInterceptor intercept(StaticParametersInterceptor java:179)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    org apache struts2 interceptor MultiselectInterceptor intercept(MultiselectInterceptor java:75)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    org apache struts2 interceptor CheckboxInterceptor intercept(CheckboxInterceptor java:94)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    org apache struts2 interceptor FileUploadInterceptor intercept(FileUploadInterceptor java:235)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor ModelDrivenInterceptor intercept(ModelDrivenInterceptor java:89)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor ScopedModelDrivenInterceptor intercept(ScopedModelDrivenInterceptor java:130)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    org apache struts2 interceptor debugging DebuggingInterceptor intercept(DebuggingInterceptor java:267)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor ChainingInterceptor intercept(ChainingInterceptor java:126)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor PrepareInterceptor doIntercept(PrepareInterceptor java:138)
    com opensymphony xwork2 interceptor MethodFilterInterceptor intercept(MethodFilterInterceptor java:87)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor I18nInterceptor intercept(I18nInterceptor java:165)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    org apache struts2 interceptor ServletConfigInterceptor intercept(ServletConfigInterceptor java:164)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor AliasInterceptor intercept(AliasInterceptor java:179)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor ExceptionMappingInterceptor intercept(ExceptionMappingInterceptor java:176)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    org apache struts2 impl StrutsActionProxy execute(StrutsActionProxy java:52)
    org apache struts2 dispatcher Dispatcher serviceAction(Dispatcher java:488)
    org apache struts2 dispatcher ng ExecuteOperations executeAction(ExecuteOperations java:77)
    org apache struts2 dispatcher ng filter StrutsPrepareAndExecuteFilter doFilter(StrutsPrepareAndExecuteFilter java:91)
root cause

com mysql jdbc exceptions jdbc4 CommunicationsException: Communications link failure

Last packet sent to the server was 1 ms ago 
    sun reflect GeneratedConstructorAccessor29 newInstance(Unknown Source)
    sun reflect DelegatingConstructorAccessorImpl newInstance(DelegatingConstructorAccessorImpl java:27)
    java lang reflect Constructor newInstance(Constructor java:513)
    com mysql jdbc Util handleNewInstance(Util java:406)
    com mysql jdbc SQLError createCommunicationsException(SQLError java:1074)
    com mysql jdbc MysqlIO reuseAndReadPacket(MysqlIO java:2985)
    com mysql jdbc MysqlIO reuseAndReadPacket(MysqlIO java:2871)
    com mysql jdbc MysqlIO checkErrorPacket(MysqlIO java:3414)
    com mysql jdbc MysqlIO sendCommand(MysqlIO java:1936)
    com mysql jdbc MysqlIO sqlQueryDirect(MysqlIO java:2060)
    com mysql jdbc ConnectionImpl execSQL(ConnectionImpl java:2536)
    com mysql jdbc ConnectionImpl setAutoCommit(ConnectionImpl java:4874)
    com mchange v2 c3p0 impl NewProxyConnection setAutoCommit(NewProxyConnection java:881)
    org hibernate connection C3P0ConnectionProvider getConnection(C3P0ConnectionProvider java:61)
    org hibernate jdbc ConnectionManager openConnection(ConnectionManager java:423)
    org hibernate jdbc ConnectionManager getConnection(ConnectionManager java:144)
    org hibernate jdbc JDBCContext connection(JDBCContext java:119)
    org hibernate transaction JDBCTransaction begin(JDBCTransaction java:57)
    org hibernate impl SessionImpl beginTransaction(SessionImpl java:1326)
    sun reflect GeneratedMethodAccessor409 invoke(Unknown Source)
    sun reflect DelegatingMethodAccessorImpl invoke(DelegatingMethodAccessorImpl java:25)
    java lang reflect Method invoke(Method java:597)
    org hibernate context ThreadLocalSessionContext$TransactionProtectionWrapper invoke(ThreadLocalSessionContext java:301)
    $Proxy13 beginTransaction(Unknown Source)
    asiit db UserOperation listn(UserOperation java:71)
    asiit action Login execute(Login java:40)
    sun reflect NativeMethodAccessorImpl invoke0(Native Method)
    sun reflect NativeMethodAccessorImpl invoke(NativeMethodAccessorImpl java:39)
    sun reflect DelegatingMethodAccessorImpl invoke(DelegatingMethodAccessorImpl java:25)
    java lang reflect Method invoke(Method java:597)
    com opensymphony xwork2 DefaultActionInvocation invokeAction(DefaultActionInvocation java:441)
    com opensymphony xwork2 DefaultActionInvocation invokeActionOnly(DefaultActionInvocation java:280)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:243)
    com opensymphony xwork2 interceptor DefaultWorkflowInterceptor doIntercept(DefaultWorkflowInterceptor java:165)
    com opensymphony xwork2 interceptor MethodFilterInterceptor intercept(MethodFilterInterceptor java:87)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 validator ValidationInterceptor doIntercept(ValidationInterceptor java:252)
    org apache struts2 interceptor validation AnnotationValidationInterceptor doIntercept(AnnotationValidationInterceptor java:68)
    com opensymphony xwork2 interceptor MethodFilterInterceptor intercept(MethodFilterInterceptor java:87)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor ConversionErrorInterceptor intercept(ConversionErrorInterceptor java:122)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor ParametersInterceptor doIntercept(ParametersInterceptor java:195)
    com opensymphony xwork2 interceptor MethodFilterInterceptor intercept(MethodFilterInterceptor java:87)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor ParametersInterceptor doIntercept(ParametersInterceptor java:195)
    com opensymphony xwork2 interceptor MethodFilterInterceptor intercept(MethodFilterInterceptor java:87)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor StaticParametersInterceptor intercept(StaticParametersInterceptor java:179)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    org apache struts2 interceptor MultiselectInterceptor intercept(MultiselectInterceptor java:75)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    org apache struts2 interceptor CheckboxInterceptor intercept(CheckboxInterceptor java:94)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    org apache struts2 interceptor FileUploadInterceptor intercept(FileUploadInterceptor java:235)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor ModelDrivenInterceptor intercept(ModelDrivenInterceptor java:89)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor ScopedModelDrivenInterceptor intercept(ScopedModelDrivenInterceptor java:130)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    org apache struts2 interceptor debugging DebuggingInterceptor intercept(DebuggingInterceptor java:267)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor ChainingInterceptor intercept(ChainingInterceptor java:126)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor PrepareInterceptor doIntercept(PrepareInterceptor java:138)
    com opensymphony xwork2 interceptor MethodFilterInterceptor intercept(MethodFilterInterceptor java:87)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor I18nInterceptor intercept(I18nInterceptor java:165)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    org apache struts2 interceptor ServletConfigInterceptor intercept(ServletConfigInterceptor java:164)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor AliasInterceptor intercept(AliasInterceptor java:179)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor ExceptionMappingInterceptor intercept(ExceptionMappingInterceptor java:176)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    org apache struts2 impl StrutsActionProxy execute(StrutsActionProxy java:52)
    org apache struts2 dispatcher Dispatcher serviceAction(Dispatcher java:488)
    org apache struts2 dispatcher ng ExecuteOperations executeAction(ExecuteOperations java:77)
    org apache struts2 dispatcher ng filter StrutsPrepareAndExecuteFilter doFilter(StrutsPrepareAndExecuteFilter java:91)
root cause

java io EOFException: Can not read response from server  Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost 
    com mysql jdbc MysqlIO readFully(MysqlIO java:2431)
    com mysql jdbc MysqlIO reuseAndReadPacket(MysqlIO java:2882)
    com mysql jdbc MysqlIO reuseAndReadPacket(MysqlIO java:2871)
    com mysql jdbc MysqlIO checkErrorPacket(MysqlIO java:3414)
    com mysql jdbc MysqlIO sendCommand(MysqlIO java:1936)
    com mysql jdbc MysqlIO sqlQueryDirect(MysqlIO java:2060)
    com mysql jdbc ConnectionImpl execSQL(ConnectionImpl java:2536)
    com mysql jdbc ConnectionImpl setAutoCommit(ConnectionImpl java:4874)
    com mchange v2 c3p0 impl NewProxyConnection setAutoCommit(NewProxyConnection java:881)
    org hibernate connection C3P0ConnectionProvider getConnection(C3P0ConnectionProvider java:61)
    org hibernate jdbc ConnectionManager openConnection(ConnectionManager java:423)
    org hibernate jdbc ConnectionManager getConnection(ConnectionManager java:144)
    org hibernate jdbc JDBCContext connection(JDBCContext java:119)
    org hibernate transaction JDBCTransaction begin(JDBCTransaction java:57)
    org hibernate impl SessionImpl beginTransaction(SessionImpl java:1326)
    sun reflect GeneratedMethodAccessor409 invoke(Unknown Source)
    sun reflect DelegatingMethodAccessorImpl invoke(DelegatingMethodAccessorImpl java:25)
    java lang reflect Method invoke(Method java:597)
    org hibernate context ThreadLocalSessionContext$TransactionProtectionWrapper invoke(ThreadLocalSessionContext java:301)
    $Proxy13 beginTransaction(Unknown Source)
    asiit db UserOperation listn(UserOperation java:71)
    asiit action Login execute(Login java:40)
    sun reflect NativeMethodAccessorImpl invoke0(Native Method)
    sun reflect NativeMethodAccessorImpl invoke(NativeMethodAccessorImpl java:39)
    sun reflect DelegatingMethodAccessorImpl invoke(DelegatingMethodAccessorImpl java:25)
    java lang reflect Method invoke(Method java:597)
    com opensymphony xwork2 DefaultActionInvocation invokeAction(DefaultActionInvocation java:441)
    com opensymphony xwork2 DefaultActionInvocation invokeActionOnly(DefaultActionInvocation java:280)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:243)
    com opensymphony xwork2 interceptor DefaultWorkflowInterceptor doIntercept(DefaultWorkflowInterceptor java:165)
    com opensymphony xwork2 interceptor MethodFilterInterceptor intercept(MethodFilterInterceptor java:87)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 validator ValidationInterceptor doIntercept(ValidationInterceptor java:252)
    org apache struts2 interceptor validation AnnotationValidationInterceptor doIntercept(AnnotationValidationInterceptor java:68)
    com opensymphony xwork2 interceptor MethodFilterInterceptor intercept(MethodFilterInterceptor java:87)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor ConversionErrorInterceptor intercept(ConversionErrorInterceptor java:122)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor ParametersInterceptor doIntercept(ParametersInterceptor java:195)
    com opensymphony xwork2 interceptor MethodFilterInterceptor intercept(MethodFilterInterceptor java:87)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor ParametersInterceptor doIntercept(ParametersInterceptor java:195)
    com opensymphony xwork2 interceptor MethodFilterInterceptor intercept(MethodFilterInterceptor java:87)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor StaticParametersInterceptor intercept(StaticParametersInterceptor java:179)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    org apache struts2 interceptor MultiselectInterceptor intercept(MultiselectInterceptor java:75)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    org apache struts2 interceptor CheckboxInterceptor intercept(CheckboxInterceptor java:94)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    org apache struts2 interceptor FileUploadInterceptor intercept(FileUploadInterceptor java:235)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor ModelDrivenInterceptor intercept(ModelDrivenInterceptor java:89)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor ScopedModelDrivenInterceptor intercept(ScopedModelDrivenInterceptor java:130)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    org apache struts2 interceptor debugging DebuggingInterceptor intercept(DebuggingInterceptor java:267)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor ChainingInterceptor intercept(ChainingInterceptor java:126)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor PrepareInterceptor doIntercept(PrepareInterceptor java:138)
    com opensymphony xwork2 interceptor MethodFilterInterceptor intercept(MethodFilterInterceptor java:87)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor I18nInterceptor intercept(I18nInterceptor java:165)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    org apache struts2 interceptor ServletConfigInterceptor intercept(ServletConfigInterceptor java:164)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor AliasInterceptor intercept(AliasInterceptor java:179)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    com opensymphony xwork2 interceptor ExceptionMappingInterceptor intercept(ExceptionMappingInterceptor java:176)
    com opensymphony xwork2 DefaultActionInvocation invoke(DefaultActionInvocation java:237)
    org apache struts2 impl StrutsActionProxy execute(StrutsActionProxy java:52)
    org apache struts2 dispatcher Dispatcher serviceAction(Dispatcher java:488)
    org apache struts2 dispatcher ng ExecuteOperations executeAction(ExecuteOperations java:77)
    org apache struts2 dispatcher ng filter StrutsPrepareAndExecuteFilter doFilter(StrutsPrepareAndExecuteFilter java:91)

1 个答案:

答案 0 :(得分:1)

与数据库服务器的连接已断开:

  

预计读取4个字节,在连接之前读取0个字节   意外地失去了

  1. 检查您是否可以从SQL控制台进行连接。
  2. 同时检查db日志以确认此假设。
  3. 连接可能会因各种原因而丢失:

    • 您的应用服务器和数据库服务器之间的网络问题
    • 数据库服务器崩溃了
    • 网卡驱动程序错误