初学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)的更多相关文章

  1. java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)

    在更新项目之后,做了一定的改动后发现竟然报错了,刚才还好好的. java.sql.SQLException: Access denied for user 'root'@'localhost' (us ...

  2. 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 ...

  3. 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: ...

  4. Error updating database. Cause: java.sql.SQLException: Access denied for user '${username}'@'localhost' (using password: YES)

    导入别人的项目,出现一个错误,经过排查,是db.properties配置文件中的用户名与Mybatis-conf.xml配置文件中调用的用户名不一致所导致的 (db.properties中用的是nam ...

  5. 技术笔记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 ...

  6. java.sql.SQLException: Access denied for user 'scott'@'localhost' (using password: YES)

    今天用eclipse连接一下数据库,出现此异常. java.sql.SQLException: Access denied for user 'scott'@'localhost' (using pa ...

  7. java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) 解决办法

    一.背景 在Spark中,将DStream写入到MySQL出现错误:java.sql.SQLException: Access denied for user 'root'@'localhost' ( ...

  8. [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 ...

  9. 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 ...

随机推荐

  1. Mybatis基本用法

    搭建mybatis环境 1, 导入需要的jar包 mybatis-*.*.*.jar ojdbc6.jar 2, 配置mybatis的总配置文件: mybatis-config.xml 配置根标签 & ...

  2. Pacemaker、corosync

    pacemaker详细介绍: http://blog.51cto.com/freeloda/1274533 corosync详细介绍: http://blog.51cto.com/freeloda/1 ...

  3. 软工实践Alpha冲刺(5/10)

    队名:起床一起肝活队 组长博客:博客链接 作业博客:班级博客本次作业的链接 组员情况 组员1(队长):白晨曦 过去两天完成了哪些任务 描述: 已经解决登录注册等基本功能的界面. 完成了主界面的基本布局 ...

  4. PHP面向对象练习

    练习内容:随机生成一个字符串 代码: <?phpclass randstring{ private $length; private $type; private $one = array(0, ...

  5. hdu 1551 Cable master (二分法)

    Cable master Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota ...

  6. POJ 2983-Is the Information Reliable

    Description The galaxy war between the Empire Draco and the Commonwealth of Zibu broke out 3 years a ...

  7. 圆盘自动机 cell

    圆盘自动机 cell 一个n-m圆盘自动机,包含n个排列成一圈的方格,它们按1至n编号.每个方格中有一个整数,范围[0,m-1] .圆盘会进行d操作,每次d操作会使得每个方格中的数同时变换,变换为与其 ...

  8. 转:Intent与PendingIntent

    intent英文意思是意图,pending表示即将发生或来临的事情. PendingIntent这个类用于处理即将发生的事情.比如在通知Notification中用于跳转页面,但不是马上跳转. Int ...

  9. hdu 5072 计数+容斥原理

    /* 题意: 给出n个数(n<100000), 每个数都不大于100000,数字不会有重复.现在随意抽出3个,问三个彼此互质 或者 三个彼此不互质的数目有多少. 思路: 这道题反着想,就是三个数 ...

  10. Spring 的IOC 和Aop

    Spring 的IOC 和Aop