ASD
ASD

Reputation: 735

Cannot connect to MySQl database from Eclipse DataSource Explorer

http://motionsharing.com/site/download/acefad55f1e81e456d71a7448b278915

Cannot connect to MySQl database from Eclipse DataSource Explorer.

I tune appropriate driver but I cannot to connect. P.S.: I can connect to derby db and I can connect to mysql db but only from code, but I want to connect to mysql db from Data Source Explorer to get posivbilities to create tables and so on.

What is wrong ?

I can connect through code.

public static void main(String args[]) {
    try {
        Class.forName("com.mysql.jdbc.Driver");
        System.out.println("Driver loading success!");
        String url = "jdbc:mysql://localhost:3306/mydb";
        String name = "root";
        String password = "root";
        try {
            Connection con = DriverManager.getConnection(url, name, password);
            System.out.println("Connected.");
            con.close();
            System.out.println("Disconnected.");
        } catch (SQLException e) {
            e.printStackTrace();
        }

    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
}

Upvotes: 3

Views: 12195

Answers (2)

teteArg
teteArg

Reputation: 4024

In Driver Properties make sure to use:

URL: jdbc:mysql://localhost:3306/schema_name

Database: schema_name

So Eclipse will show the tables en the Data Source Explorer.

Upvotes: 2

adarshr
adarshr

Reputation: 62613

You need to download MySQL JDBC driver and add it to the settings.

You will see these screens when you try to create a new connection profile in Datasource Explorer. In the last step, you'll have to point to the right downloaded JAR file.

enter image description here enter image description here enter image description here enter image description here

Upvotes: 5

Related Questions