java.sql.SQLException: Access denied for user 'roo'@'localhost' (using password: YES)
初学mysql,安装了mysql8.0.11,激动的用jdbc连接数据库,出现error,折腾了三天依旧无解,最后无奈装了比较稳定的mysql5.5,问题得以解决,很迷,但只要error没了就开心。
在此记录我傻傻坚持的3天。
环境:win10 + mysql8.0.11 + eclipse
1.代码
import java.sql.*;
public class SqlConnection {
private static final String URL = "jdbc:mysql://127.0.0.1:3306/test?useSSL=false&serverTimezone=GMT";
private static final String NAME = "root";
private static final String PASSWORD = "root";
public void TheSqlConnection() {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
System.out.println("连接成功");
} catch (ClassNotFoundException e) {
System.out.println("连接失败");
e.printStackTrace();
}
Connection conn = null;
try {
System.out.println("开始获取");
conn = DriverManager.getConnection(URL, NAME, PASSWORD);
System.out.println("获取成功");
} catch (SQLException e) {
System.out.println("获取失败");
e.printStackTrace();
}
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
conn = null;
}
}
}
}
public class MainClass {
public static void main(String[] args) {
// TODO Auto-generated method stub
new SqlConnection().TheSqlConnection();
}
}
2.项目结构

已经导入驱动包
3.错误信息

java.sql.SQLException: Access denied for user 'roo'@'localhost' (using password: YES)
出现这个错误一般就是用户名或者密码错误了,经多次检查用户名和密码正确。
4.命令行可以登陆

5.navicat也可以连接上

错误发生处:DriverManager.getConnection(URL, NAME, PASSWORD);
这个问题是真的皮,问朋友问学长问老师,能问的都请教了遍,都没解决,心累啊。
最后的最后,卸载干净mysql8.0.11,重装上mysql5.5.重新运行代码,问题没了o(* ̄▽ ̄*)o

java.sql.SQLException: Access denied for user 'roo'@'localhost' (using password: YES)的更多相关文章
- java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)
在更新项目之后,做了一定的改动后发现竟然报错了,刚才还好好的. java.sql.SQLException: Access denied for user 'root'@'localhost' (us ...
- java.sql.SQLException: Access denied for user 'sa'@'localhost' (using password: YES)
1.错误描述 ERROR:2015-05-01 23:43:04[localhost-startStop-1] - HHH000319: Could not get database metadata ...
- java.sql.SQLException: Access denied for user 'sa'@'localhost' (using password: NO)
1.错误描述 INFO:2015-05-01 16:53:29[main] - HHH000228: Running hbm2ddl schema update INFO:2015-05-01 16: ...
- Error updating database. Cause: java.sql.SQLException: Access denied for user '${username}'@'localhost' (using password: YES)
导入别人的项目,出现一个错误,经过排查,是db.properties配置文件中的用户名与Mybatis-conf.xml配置文件中调用的用户名不一致所导致的 (db.properties中用的是nam ...
- 技术笔记1:java.sql.SQLException: Access denied for user 'root'@'localhost' (using password)
在myEclipse10中运行java项目的时候,遇到java.sql.SQLException: Access denied for user 'root'@'localhost' (using p ...
- java.sql.SQLException: Access denied for user 'scott'@'localhost' (using password: YES)
今天用eclipse连接一下数据库,出现此异常. java.sql.SQLException: Access denied for user 'scott'@'localhost' (using pa ...
- java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) 解决办法
一.背景 在Spark中,将DStream写入到MySQL出现错误:java.sql.SQLException: Access denied for user 'root'@'localhost' ( ...
- [Spring MVC - 2A] - java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
严重: Servlet.service() for servlet [springMVC] in context with path [/ExceptionManageSystem] threw ex ...
- java.sql.SQLException: Access denied for user 'Administrator'@'localhost' (using password: YES)
早上在做MyBatis+Spring整合的时候爆了个奇葩的bug: 十月 19, 2017 11:18:11 上午 org.springframework.context.support.Abstra ...
随机推荐
- 【Substring with Concatenation of All Words】cpp
题目: You are given a string, s, and a list of words, words, that are all of the same length. Find all ...
- c语言在windows下和Mac下的不同表现!
最近给一个等级考试的C语言培训班上课,学生问起一些++的问题.让我好生为难.因为这些不同的编译器处理方式,在不同的系统下表现并不一致. 不管你洋洋洒洒论述多么一大篇,在事实面前就一下显得苍白了.虽然这 ...
- webdriver--单选、复选及下拉框的定位
单选radiobutton的操作 两种情况,一种是各个button元素的属性都有唯一定位值,可以直接用属性唯一值定位:另一种就是一组各方面属性值都一样的radiobutton,除了text,可以用组元 ...
- mongo数据库 启动报错
报错信息如下: [root@166 bin]# mongoMongoDB shell version v3.4.6-22-ga109a23connecting to: mongodb://127.0. ...
- 原始套接字--arp相关
arp请求示例 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <un ...
- 201621123034 《Java程序设计》第11周学习总结
作业11-多线程 1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结多线程相关内容. 2. 书面作业 本次PTA作业题集多线程 1. 源代码阅读:多线程程序BounceThread ...
- windows系统设备管理器显示全部硬件
下面的小命令能让隐藏的未卸载掉的硬件设备彻底现身:开始-运行-CMD C:\> C:\>start devmgmt.msc 之后再在Windows 的设备管理器中,单击菜单“显示”-“显示 ...
- zoj 2110 Tempter of the Bone (dfs)
Tempter of the Bone Time Limit: 2 Seconds Memory Limit: 65536 KB The doggie found a bone in an ...
- 方伯伯的OJ ( onlinejudge )
方伯伯的OJ 题目描述 方伯伯正在做他的OJ.现在他在处理OJ 上的用户排名问题. OJ 上注册了n 个用户,编号为1 ∼ n,一开始他们按照编号排名.方伯伯会按照心情对这些用户做以下四种操作,修改用 ...
- freemarker的简单入门程序
本文主要介绍了freemarker的常用标签<#list> <#import> <#assign> <#if> <#else> &l ...