初学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. js点击重置按钮重置表单

    <html><head><script type="text/javascript">function formReset(){document ...

  2. USACO Section1.3 Ski Course Design 解题报告

    skidesign解题报告 —— icedream61 博客园(转载请注明出处)------------------------------------------------------------ ...

  3. thinkPHP 表单自动验证功能

    昨天晚上我们老大叫我弄表单自动验证功能,愁了半天借鉴了好多官网的知识,才出来,诶,总之分享一下我自己的成果吧! thinkphp 在Model基类为我们定义了自动验证的函数和正则表达式,我们只需要在对 ...

  4. Remote使用出现的问题及解决办法

    最近尝试跟着虫师的OP模式所写的bbs代码,应用自己的项目尝试修改,在第一步Remote启动Firefox上便出错,当前selenium2.53,firefox47.1,selenium server ...

  5. ptmalloc,tcmalloc和jemalloc内存分配策略研究 ? I'm OWen..

    转摘于http://www.360doc.com/content/13/0915/09/8363527_314549949.shtml 最近看了glibc的ptmaoolc,Goolge的tcmall ...

  6. Linux利用OneinStack搭建环境

    OneinStack官方网站:https://oneinstack.com 介绍 OneinStack支持以下数种环境组合: LNMP(Linux + Nginx+ MySQL+ PHP) LAMP( ...

  7. nyoj 题目21 三个水杯

    三个水杯 时间限制:1000 ms  |  内存限制:65535 KB 难度:4   描述 给出三个水杯,大小不一,并且只有最大的水杯的水是装满的,其余两个为空杯子.三个水杯之间相互倒水,并且水杯没有 ...

  8. NSOperation 开发

    目录 1.简介 2.Operation对象 3.自定义Operation对象 4.通过Operation Queues运行Operation对象 5.手动运行Operation对象 一.简介 Coco ...

  9. Java分布式数据导出实践

    伴随业务发展日益剧增,对数据的要求越来越多也越来越高. 用户在浏览器发起导出请求--web服务器接收请求--请求后台获取数据--数据统计后生成excel或其他图标--响应给客户端 整个过程至少5步,才 ...

  10. 【CF Round 439 E. The Untended Antiquity】

    time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standa ...