2012-11-14 39 views
1

好吧,我從使用XAMPP和即時通過虛擬主機我的hiscores通過虛擬主機,我如何編輯此行,以便它與它一起工作,當我運行服務器,它拋出一個錯誤。MySQL/Java數據庫

public static void createConnection() { 
     try { 
      Class.forName("com.mysql.jdbc.Driver").newInstance(); 
      con = DriverManager.getConnection(
        "jdbc:mysql://fdb4.awardspace.com/", "1191306_hiscores", "passremoved"); 
      stmt = con.createStatement(); 
        Misc.println("Connected"); 
     } catch (Exception e) { 
      Misc.println("Connection Problem"); 
     }] 

曾經是localhost/hiscores顯然不會工作了。

+2

如果它拋出一個錯誤,看到*什麼*(和哪裏)是拋出的確切異常總是有用的。有很多東西可能是錯誤的 - 添加諸如'e.printStackTrace()'之類的東西並粘貼輸出。 – andri

+0

你能提供異常跟蹤嗎? – zaffargachal

+0

觀察:1)如果您想檢查連接是否建立,您爲什麼要創建語句?你可以像這樣檢查:if(con!= null){System.out.println(「Connection established」); } 2)爲什麼try/catch塊中沒有「finally」子句會關閉連接? –

回答

0

沒有堆棧跟蹤這很難,但我注意到,你缺少從您的網址數據庫的名稱,它應該是這樣的:

con = DriverManager.getConnection(
        "jdbc:mysql://fdb4.awardspace.com/hiscores", "1191306_hiscores", "passremoved"); 

注意jdbc:mysql://fdb4.awardspace.com/hiscoresjdbc:mysql://fdb4.awardspace.com/

0

Awardspace不要」允許遠程連接到免費帳戶上的MySQL數據庫。

您可以使用http://www.freesqldatabase.com/

但非常有限,只有5MB。這是我發現的唯一免費服務,提供遠程連接到MySQL數據庫。