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

  • 相关阅读:
    终于成功发布我的博客园处女贴,不过,真的颇费周章,两个htmleditor都非常不好用~~
    全文本代码着色(带源码和示例)
    BlogBench Ver 1.0 发布
    [在windows上使用Unix工具]cygwin
    Linux下压缩与解压
    Linux设置界面或命令行启动
    perl模块安装
    Linux下patch的制作和应用
    TAR命令参数详解
    在windows上使用Sysinternals工具
  • 原文地址:https://www.cnblogs.com/smuzoey/p/11400454.html
Copyright © 2011-2022 走看看