Java.sql.SQLException:Access denied for user ' roo ' @ ' localhost ' (using Password:yes)

Source: Internet
Author: User

Beginner MySQL, installed mysql8.0.11, excited to connect the database with JDBC, error, tossing for three days still no solution, finally helpless installed a more stable mysql5.5, the problem can be solved, very fascinated, but as long as the error is not happy.

In this record I foolishly insisted on 3 days.

Environment: Win10 + mysql8.0.11 + eclipse

1. Code

1 ImportJava.sql.*;2 3  Public classSqlConnection {4     Private Static FinalString URL = "Jdbc:mysql://127.0.0.1:3306/test?usessl=false&servertimezone=gmt";5     Private Static FinalString NAME = "root";6     Private Static FinalString PASSWORD = "root";7      Public voidthesqlconnection () {8         Try {9Class.forName ("Com.mysql.cj.jdbc.Driver");TenSYSTEM.OUT.PRINTLN ("Connection succeeded"); One}Catch(ClassNotFoundException e) { ASystem.out.println ("Connection Failed"); - e.printstacktrace (); -         } theConnection conn =NULL; -         Try { -System.out.println ("Get Started"); -conn =drivermanager.getconnection (URL, NAME, PASSWORD); +System.out.println ("Get Success"); -}Catch(SQLException e) { +System.out.println ("Get Failed"); A e.printstacktrace (); at         } -         if(Conn! =NULL) { -             Try { - conn.close (); -}Catch(SQLException e) { - e.printstacktrace (); inconn =NULL; -             } to         } +     } -}
1  Public class MainClass {23      Public Static void Main (string[] args) {4         // TODO auto-generated Method Stub 5         New SqlConnection (). Thesqlconnection (); 6     }78 }

2. Project Structure

Drive package already imported

3. Error messages

Java.sql.SQLException:Access denied for user ' roo ' @ ' localhost ' (using Password:yes)

This error is usually the user name or password is wrong, after several checks the user name and password is correct.

4. Command line can login

5.navicat can also be connected to the

Error occurred at: drivermanager.getconnection (URL, NAME, PASSWORD);

This question is true skin, ask a friend ask seniors ask teacher, can ask all consulted all over, did not solve, heart tired ah.

Finally, uninstall the clean mysql8.0.11, reload the mysql5.5. Rerun the code, the problem is Gone O (* ̄▽ ̄*) o

Java.sql.SQLException:Access denied for user ' roo ' @ ' localhost ' (using Password:yes)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.