Eclipse cannot connect to the mysql database through mysql-eclipse. please give me the answer!

Source: Internet
Author: User
** Mysql5.6 was used for JDBC connection, but now it cannot be used. I have found the cause on the internet but cannot find a solution, the connection JAR package is mysql-connector-java-5.1.26-bin.jar, please know the great God to answer a little ** This is to use JDBC connection MYSQLimportjava. SQL. *; publicclassTestMysqlConnection {publicstaticvoidmain (String [] args) {Connectioncon... connect mysqleclipse to mysqljava

I used mysql 5.6 to connect to mysql using JDBC, but now it cannot be used. I am not clear about the reason and have found it online, but I cannot find a solution, connecting JAR package is mysql-connector-java-5.1.26-bin.jar, please know the great God to answer the younger brother

This is to use JDBC to connect to MYSQL

Import java. SQL .*;

Public class TestMysqlConnection {
Public static void main (String [] args ){
Connection conn = null;
Try {
Class. forName ("com. mysql. jdbc. Driver ");
Conn = DriverManager. getConnection ("jdbc: mysql: // localhost/bbs", "root", "82215378 ");
} Catch (ClassNotFoundException e ){
E. printStackTrace ();
} Catch (SQLException e ){
E. printStackTrace ();
} Finally {
Try {
If (conn! = Null ){
Conn. close ();
Conn = null;
}
} Catch (SQLException e ){
E. printStackTrace ();
}
}
}

The error is as follows:
Com. mysql. jdbc. exceptions. jdbc4.MySQLNonTransientConnectionException: Communication link failure, message from server: "Can't get hostname for your address"
At sun. reflect. NativeConstructorAccessorImpl. newInstance0 (Native Method)
At sun. reflect. NativeConstructorAccessorImpl. newInstance (Unknown Source)
At sun. reflect. DelegatingConstructorAccessorImpl. newInstance (Unknown Source)
At java. lang. reflect. Constructor. newInstance (Unknown Source)
At com. mysql. jdbc. Util. handleNewInstance (Util. java: 411)
At com. mysql. jdbc. Util. getInstance (Util. java: 386)
At com. mysql. jdbc. SQLError. createSQLException (SQLError. java: 1015)
At com. mysql. jdbc. SQLError. createSQLException (SQLError. java: 989)
At com. mysql. jdbc. SQLError. createSQLException (SQLError. java: 975)
At com. mysql. jdbc. MysqlIO. doHandshake (MysqlIO. java: 1112)
At com. mysql. jdbc. ConnectionImpl. coreConnect (ConnectionImpl. java: 2486)
At com. mysql. jdbc. ConnectionImpl. connectOneTryOnly (ConnectionImpl. java: 2519)
At com. mysql. jdbc. ConnectionImpl. createNewIO (ConnectionImpl. java: 2304)
At com. mysql. jdbc. ConnectionImpl. (ConnectionImpl. java: 834)
At com. mysql. jdbc. JDBC4Connection. (JDBC4Connection. java: 47)
At sun. reflect. NativeConstructorAccessorImpl. newInstance0 (Native Method)
At sun. reflect. NativeConstructorAccessorImpl. newInstance (Unknown Source)
At sun. reflect. DelegatingConstructorAccessorImpl. newInstance (Unknown Source)
At java. lang. reflect. Constructor. newInstance (Unknown Source)
At com. mysql. jdbc. Util. handleNewInstance (Util. java: 411)
At com. mysql. jdbc. ConnectionImpl. getInstance (ConnectionImpl. java: 416)
At com. mysql. jdbc. NonRegisteringDriver. connect (NonRegisteringDriver. java: 346)
At java. SQL. DriverManager. getConnection (Unknown Source)
At java. SQL. DriverManager. getConnection (Unknown Source)
At TestMysqlConnection. main (TestMysqlConnection. java: 8)

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.