这个问题已经被问过了,但是没有一个解决方案对我有用。我收到以下错误
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
当我执行以下代码时
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class MyFirstDBConn {
static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
static final String DB_URL = "jdbc:mysql://localhost/repository";
// Database credentials
static final String USER = "root";
static final String PASS = "pass";
public static void main(String[] args) {
try{
System.out.println("Register the DriverManager with DB driver");
Class.forName(JDBC_DRIVER );
Connection conn = DriverManager.getConnection(DB_URL, USER, PASS);
Statement statement = conn.createStatement();
......
}
}
}
请帮助。