`
huaye2007
  • 浏览: 38616 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
文章分类
社区版块
存档分类
最新评论

org.hibernate.exception.JDBCConnectionException: Cannot open connection

 
阅读更多

org.hibernate.exception.JDBCConnectionException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:97)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:449)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
at org.hibernate.jdbc.BorrowedConnectionProxy.invoke(BorrowedConnectionProxy.java:74)
at $Proxy0.createStatement(Unknown Source)
at blazefire.fee.TestConnection.testConnection(TestConnection.java:18)
at blazefire.fee.ServerCheckServlet.doGet(ServerCheckServlet.java:44)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
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:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
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:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1013)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2238)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2159)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:792)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:154)
at org.logicalcobwebs.proxool.DefaultConnectionBuilder.buildConnection(DefaultConnectionBuilder.java:39)
at org.logicalcobwebs.proxool.Prototyper.buildConnection(Prototyper.java:159)
at org.logicalcobwebs.proxool.ConnectionPool.getConnection(ConnectionPool.java:211)
at org.logicalcobwebs.proxool.ProxoolDriver.connect(ProxoolDriver.java:89)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:207)
at org.hibernate.connection.ProxoolConnectionProvider.getConnection(ProxoolConnectionProvider.java:75)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
... 19 more
Caused by: java.sql.SQLException: Access denied for user 'mysqladmin'@'localhost' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:935)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4101)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1300)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2337)
at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2177)
... 39 more

mysql数据库在Linux上,因添加的用户不能本地登录,只能远程登录,而root用户只能本地登录不能远程登录,所以数据库连接用户名和密码都正确的话,就看下IP,把localhost或者127.0.0.1改成服务器IP就可以了。

分享到:
评论

相关推荐

    Hibernate配置常见错误

    错误表现:如“org.hibernate.exception.JDBCConnectionException: Cannot open connection”,表明Hibernate无法建立与数据库的连接。 解决方案:检查数据库URL、用户名和密码是否正确。此外,还需确认数据库服务...

    Hibernate+c3p0连接池SQLServer 2000

    [http60-Processor3][org.apache.struts.action.RequestProcessor][WARN] - Unhandled Exception thrown: class org.hibernate.exception.JDBCConnectionException [http60-Processor1][org.hibernate.util....

    MySQL+Hibernate下连接空闲8小时自动断开问题解决方案.docx

    在本文中,出现了一个javax.servlet.ServletException: org.hibernate.exception.JDBCConnectionException 异常,这是由于连接idle时间太长导致的。这个异常是 Hibernate 在试图执行查询时抛出的,表示JDBC 连接已经...

    MySQL数据库服务器下C3P0连接池的配置.pdf

    项目的应用程序部署好后,每过一段时间(比如一个晚上),应用程序没有被调用,然后一旦程序访问MySQL数据库就会抛出异常:java代码org.hibernation.exception.JDBCConnectionException:could not execute query。...

    Hibrenate 学习摘记

    - **JDBCConnectionException**:当使用 JDBC 遇到连接问题时,如无法建立连接或连接超时等,可能会抛出此异常。 - **SQLGrammarException**:如果执行的 SQL 语句语法有误,则会抛出该异常。 - **...

Global site tag (gtag.js) - Google Analytics