简体   繁体   English

无法从Ubuntu中的webapp连接到MySQL

[英]Can't connect to MySQL from webapp in Ubuntu

I have a MySQL database I'm able to connect via the command prompt and the MySQL administration tool but using the same credentials in a Web application in a Tomcat server on the same server gives me this error: 我有一个MySQL数据库,可以通过命令提示符和MySQL管理工具进行连接,但是在同一服务器上的Tomcat服务器中的Web应用程序中使用相同的凭据会出现以下错误:

javax.servlet.ServletException : org.apache.commons.dbcp.SQLNestedException : Cannot create PoolableConnectionFactory (Could not create connection to database server. Attempted reconnect 3 times. Giving up.) javax.servlet.ServletExceptionorg.apache.commons.dbcp.SQLNestedException :无法创建PoolableConnectionFactory (无法创建与数据库服务器的连接。尝试重新连接3次。放弃。)

Which I recognize as an incorrect credentials issue. 我认为这是不正确的凭据问题。 I checked that the MySQL server is listening on port 3306 using netstat. 我检查了MySQL服务器是否正在使用netstat侦听端口3306。 I don't have the mysql root credentials but I created a new account and granted all priviledges to it and are the ones used to connect both using the command prompt and the MySQL admin tool. 我没有mysql根凭据,但是我创建了一个新帐户并授予了所有权限,并且使用命令提示符和MySQL管理工具来连接这两个帐户。

Turned out to be a caching issue. 原来是一个缓存问题。 Disabled the context caching in the web application in order to "see" the changes. 禁用Web应用程序中的上下文缓存,以便“查看”更改。 Windows doesn't show this behavior/issue. Windows不会显示此行为/问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM