Home >Database >Mysql Tutorial >Why Am I Still Getting 'Exception in thread 'main' java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO)'?

Why Am I Still Getting 'Exception in thread 'main' java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO)'?

Patricia Arquette
Patricia ArquetteOriginal
2024-11-12 10:31:021031browse

Why Am I Still Getting

Resolving "Exception in thread "main" java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO)" Error

Issue:

The Java program is encountering a SQL exception indicating that the user connecting to the MySQL database does not have permission to access the data. Despite attempts to modify user permissions and password, the error persists.

Answer:

It is likely that Eclipse is not running the intended MainApp class, which is the source of the SQL query. Instead, it is running a different class (com.mysql.cj.jdbc.admin.TimezoneDump) that also contains a main method.

Solution:

To resolve this issue:

  1. Right-click on the MainApp.java file in the Eclipse IDE.
  2. Select "Run As" and then choose "Java Application".

This will launch the MainApp class and resolve the SQL exception caused by incorrect user permission or an invalid connection attempt.

The above is the detailed content of Why Am I Still Getting 'Exception in thread 'main' java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO)'?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn