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

  • 相关阅读:
    4个python常用高阶函数的使用方法
    Python基础教程:input()输入与数据类型转换
    vue.js 使用 fastclick解决移动端click事件300毫秒延迟方法
    react组件通信
    深入了解react中 this.setState方法
    Ant Design Mobile 报Cannot find module 'react-scripts/package.json' 错误
    vue-router的两种模式的区别
    Vue项目优化指南
    React开发常用设计模式-组件样式
    axios发送post请求,提交表单数据
  • 原文地址:https://www.cnblogs.com/smuzoey/p/11400454.html
Copyright © 2011-2022 走看看