zoukankan      html  css  js  c++  java
  • [JavaEE]连接数据库遇到的问题

    问题1:

    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

    需要导入mysql的jar包,我是ubuntu的系统

    进入mysql官网    https://dev.mysql.com/downloads

    然后点击connector J

    windows下载zip,ubuntu下载tar.gz,但是根据电脑系统选择的Ubuntu只有deb,所以要点击旁边的“Looking for previous GA versions?”,然后进行下载

    下载后解压
    sudo tar -zxvf ......

    然后将文件中的bin.jar后缀名的jar包移动到eclipse里你存储代码的位置

    如图移动。

    点击右键然后Build Path, 然后选择add....然后即可

    Referenced Libraries中有这个mysql ...bin.jar,这样就完成了

    问题2:

    WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

    没有设置SSL,修改JDBC连接的url

    初始:
    final static String url = "jdbc:mysql://localhost:3306/SuperBookData";
    
    在后面+上“?useUnicode=true&characterEncoding=utf-8&useSSL=false”
    修改为: final
    static String url = "jdbc:mysql://localhost:3306/SuperBookData?useUnicode=true&characterEncoding=utf-8&useSSL=false";

    问题3:

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

    进入mysql
    sudo mysql -uroot -p

    使用user数据库
    use user;

    展示一些东西
    select user, plugin from mysql.user;

    更改 我的用户名密码都是root
    update mysql.user set authentication_string=PASSWORD('root'),plugin='mysql_native_password' where user='root';

    刷新下
    flush privileges;

    end

  • 相关阅读:
    java:UDP广播发送与接收数据报实现
    使用Python自由切分pdf文件提取任意页面
    python实现 -- 盆友圈九宫格
    三次登陆
    django 连接 已有数据库 导出 models表
    默认列表转字典
    代码中的去掉注释
    python 列表套字典 根据相同的key分组
    python 列表套列表去重,列表套字典去重
    Tengine更新安装
  • 原文地址:https://www.cnblogs.com/smuzoey/p/11400454.html
Copyright © 2011-2022 走看看