Mysql connection Error

Source: Internet
Author: User
1. the program connecting Unknowncharacterset: utf8mb4 is packageqdu. wxyz. db; importjava. SQL. connection; importjava. SQL. driverManager; importjava. SQL. SQLException; publicclassConn {staticConnectionconn; publicConn () {connnull;} public

1. the program connecting Unknown character set: 'utf8mb4' is package qdu. wxyz. db; import java. SQL. connection; import java. SQL. driverManager; import java. SQL. SQLException; public class Conn {static Connection conn; public Conn () {conn = null;} public

1. Unknown character set: 'utf8mb4'

The Connection Program is:

Package qdu. wxyz. db;


Import java. SQL. Connection;
Import java. SQL. DriverManager;
Import java. SQL. SQLException;


Public class Conn {
Static Connection conn;
Public Conn (){
Conn = null;
}
Public Connection getConnection (){
Try {
Class. forName ("com. mysql. jdbc. Driver ");
Conn =
DriverManager. getConnection ("jdbc: mysql: // localhost: 3306/wxyz? UseUnicode = true & characterEncoding = UTF-8 ",
"Ximo", "ximo"); // url, username, password;
// System. out. println (conn + "123 ");
} Catch (ClassNotFoundException e ){
// TODO Auto-generated catch block
E. printStackTrace ();
}
// Connect to the database
Catch (SQLException e ){
// TODO Auto-generated catch block
E. printStackTrace ();
}
Return conn;
}
}


The user name and password are correct. An error occurred while running.

Solution: Wrong driver, different versions will have this error, the modified version corresponding to "mysql5.6 corresponding mysql-connertor-java-5.1.30-bin.jar

> Mysql-connertor-java-5.1.8-bin.jar for mysql6.0



2. If the user password is incorrect, run the following command:

View all users in the MYSQL database
Mysql> select distinct concat ('user: ''', User, ''' @ ''', host, '''; ') AS query FROM mysql. user;

The command for permission is:

View permissions of a specific user in the database
Mysql> show grants for 'cactiuser' @ '% ';

Mysql> select * from mysql. user where user = 'cactiuser' \ G

To view the structure of a user table, you can use the table structure to query specific items.
Mysql> desc mysql. user;

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.