线上的java项目访问不到线上数据库,但是这个数据库我本地可以连接到,求解
java.lang.Exception: 数据库连接失败:Cannot create PoolableConnectionFactory (Server connection failure during transaction. Due to underlying exception: 'java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)'.** BEGIN NESTED EXCEPTION **
java.sql.SQLException
MESSAGE: Access denied for user 'root'@'localhost' (using password: YES)
STACKTRACE:
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:885)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3421)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1247)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2924)
at com.mysql.jdbc.Connection.<init>(Connection.java:1555)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)
at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at com.xabeiying.lefu.server.utils.ConnectionToMysql.getConnectionDB(ConnectionToMysql.java:103)
at com.xabeiying.lefu.server.dao.ZFDao.getzfbddh11sc(ZFDao.java:58)
at com.xabeiying.lefu.server.action.GetJSWYWXAction.doPost(GetJSWYWXAction.java:217)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1539)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1495)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
** END NESTED EXCEPTION **
这个项目的app端可以连接到数据库(登录注册),但是后台连接不到数据库(无法登录) 求大神解答!
这个配置文件是没有问题的,我本地也在用这个配置文件,本地和线上是一个数据库.
数据库是mysql,安装在liunx上,项目也在同一台服务器上面.
现在这个服务器上的其他项目连接这个数据库没有问题,只有这个项目的后台连接不上数据库!
回答:
可能是没有给mysql root用户设初始密码吧
回答:
是不是你把本地连接给关了
回答:
select user, host from mysql.user 看看你就知道了
回答:
mysql server 的设置里面,ip 没有指定 localhost 吧。如果用 0.0.0.0 用 localhost 就能访问吧
回答:
回答:
我的是这样 通过mysql命令行或者管理工具可以连接,但是通过启动java项目就连接报错(如图) 额,什么 鬼呢?
回答:
先去部署的机器上面,使用mysql客户端工具,用数据库用户和密码,保证连上mysql;再考虑你的程序问题
回答:
老哥解决了吗,我也碰到这个问题
以上是 线上的java项目访问不到线上数据库,但是这个数据库我本地可以连接到,求解 的全部内容, 来源链接: utcz.com/p/167844.html