2016-03-08 82 views
0

Im我開始使用Eclipse IoT並嘗試創建SQL連接器時出現以下錯誤。我在窗口中添加了類路徑,並將相應的.jar庫添加到項目中,如https://stackoverflow.com/questions/8745872/classnotfoundexception-com-mysql-jdbc-drive中的建議。我無法得到爲什麼我仍然得到這個錯誤。有任何想法嗎?爲什麼我總是在Eclipse IoT上收到ClassNotFoundException:com.mysql.jdbc.Driver錯誤

生成錯誤代碼:

public static void getConnection(){ 
    try{ 
     Class.forName("com.mysql.jdbc.Driver"); 
     } 
     catch (ClassNotFoundException e){ 
      System.out.print(" Class.forName cannot be found"); 
      e.printStackTrace(); 
     } 

而且我得到這個:

Class.forName cannot be foundjava.lang.ClassNotFoundException: com.mysql.jdbc.Driver 
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
at java.lang.Class.forName0(Native Method) 
at java.lang.Class.forName(Class.java:264) 
at controller.establishConnection.getConnection(establishConnection.java:17) 

回答

0

如果一個Web項目:檢查是否罐子(或包含的jar文件夾)確實在項目的Deployment Assembly中(在項目屬性中設置)。如果沒有,請添加它。

+0

這不是一個web項目,它將在英特爾Edison主板上運行。所以Eclipse將它加載到電路板上。 – JuanV

相關問題