Solutions to several problems with Java connection to MySQL database.

Source: Internet
Author: User

Today, for a connection to the database to get information to use for the ListView, for a full 5 hours.

Some of the problems that arise are:

The first is, drivermanager.getconnection (URL, user, pwd), the code executed before this function is successful, it is not executed, and there is no error.

It means that this line of code does not work, adding a lot of anomaly testing and capturing is a kind of. Online methods have also tried a lot. And then I found out that the wrong place was mine.

The URL was incorrectly written.

Because I want to connect to the MySQL database of the machine, and I enter in the browser is to add after localhost: 8080, that is localhost:8080

So I wrote in the code to write the URL as a String url = "Jdbc:mysql://localhost:8080/mysql"; Cause an error.

The correct wording should be the port to write the database, 3306, is to change 8080 to 3306.

The second question is:

After the first problem is resolved, the compilation has a new problem, Error:java.sql.SQLException:Access denied for user ' xxxx ' @ ' localhost ' (using Password:yes)

This error was thrown, the method of the Internet a lot of, anything, and then subconsciously in my MySQL built a new user, the code was originally set up the connection user account changed, the password has changed

Reconnect, I'm done. Specifically what causes no further research.

Solutions to several problems with Java connection to MySQL database.

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.