2012-02-23 103 views
2

http://motionsharing.com/site/download/acefad55f1e81e456d71a7448b278915無法從Eclipse的數據源資源管理器

連接到MySQL數據庫無法從Eclipse的數據源資源管理器連接到MySQL數據庫。

我調整合適的驅動程序,但我無法連接。 P.S .:我可以連接到德比數據庫,我可以連接到MySQL數據庫,但只能從代碼,但我想從數據源資源管理器連接到MySQL數據庫,以獲得posivbilities來創建表等。

出了什麼問題?

我可以通過代碼連接。

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(); 
    } 
} 

回答

5

您需要download MySQL JDBC驅動程序並將其添加到設置中。

當您嘗試在Datasource Explorer中創建新的連接配置文件時,您會看到這些屏幕。在最後一步中,您必須指向正確下載的JAR文件。

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

+0

但是什麼是然後com.mysql.jdbc.Driver? – ASD 2012-02-23 21:07:05

+0

這是一個連接到MySQL數據庫的庫。如果你從我發佈的鏈接下載,你會發現它。 – adarshr 2012-02-23 21:09:01

2

在驅動程序屬性一定要使用:

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

Database: schema_name 

所以Eclipse會顯示連接的數據源資源管理器的表。

+0

沒有** schema_name **追加到URL的末尾,表節點不會展開,儘管它仍然可以顯示錶節點但不能展開,很好的回答! – zionpi 2016-03-10 10:26:31