web应用程序无法从服务器上查询MySQL。

6 浏览
0 Comments

web应用程序无法从服务器上查询MySQL。

我有一个部署在Tomcat服务器上的网页应用程序(jsf+hibernate),它试图连接到另一台服务器上的MySQL数据库。我已经将Web应用程序服务器的IP添加到连接MySQL服务器时允许的列表中。当我启动应用程序时,我得到以下错误信息:

23:55:50,077  WARN SqlExceptionHelper:144 - SQL Error: 1142, SQLState: 42000
23:55:50,077 ERROR SqlExceptionHelper:146 - SELECT command denied to user 'xxx'@'yyyy' for table 'zzz'
org.hibernate.exception.SQLGrammarException: could not extract 
ResultSet
...

请注意,我已经给予用户所有权限,而且我可以从NetBeans连接到数据库并正常查询。同时在本地主机上运行Web应用程序和MySQL也是正常的。

0
0 Comments

确保本地和远程服务器上的数据库名称相同。通常,数据库主机会在数据库名称中添加前缀或后缀,这可能与Hibernate中的数据库名称冲突。

Check if the database user has the necessary privileges to access the database. Grant the appropriate privileges if needed.

检查数据库用户是否具有访问数据库所需的权限。如果需要,授予适当的权限。

Make sure the database server is running and accessible. Check if there are any network issues or firewall rules blocking the connection.

确保数据库服务器正在运行且可访问。检查是否有任何网络问题或防火墙规则阻止连接。

Verify the connection configuration in the web application's configuration file. Make sure the database connection URL, username, and password are correct.

验证Web应用程序配置文件中的连接配置。确保数据库连接URL、用户名和密码正确。

Check if there are any errors or exceptions in the web application's logs related to the database connection. Fix any issues found.

检查与数据库连接相关的Web应用程序日志中是否有任何错误或异常。修复任何发现的问题。

If using a connection pool, make sure the pool configuration is correct and the pool is properly initialized.

如果使用连接池,请确保配置正确,并且连接池已正确初始化。

Restart the web application and try again. Sometimes a restart can resolve connection issues.

重新启动Web应用程序,然后重试。有时重新启动可以解决连接问题。

If the above steps do not resolve the issue, consider reviewing the database configuration and permissions on the server side. It is also helpful to consult the documentation or seek assistance from the database hosting provider or server administrator.

如果上述步骤无法解决问题,请考虑检查服务器端的数据库配置和权限。查阅文档或向数据库托管提供商或服务器管理员寻求帮助也是有帮助的。

Remember to always secure the database connection by using a strong password and encrypting the connection if necessary.

请记住,始终使用强密码保护数据库连接,并在必要时加密连接。

0