[分享]JDBC連MySQL

看板java作者 (我上了賊船了囧)時間15年前 (2010/07/27 09:16), 編輯推噓5(504)
留言9則, 9人參與, 最新討論串1/1
最近在練習SQL語法,手上沒其他資料庫軟體可用,只好拿mysql來用 好不容易找到mysql的jdbc (容我抱怨一下mysql的官網,下載失敗重連竟然還要你填一堆資料,然後最少三天 再把東西寄給你....) mysql裝完,classpath設完,寫個測試來看看有沒有連到 結果出現 com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. 看到這個我囧了,很明顯是連不到資料庫,防火牆也關掉後 還是出現這個問題 努力奮戰半個小時,在mysql官網找到解答Orz http://bugs.mysql.com/bug.php?id=47494 (最後一個回覆) An entry has been added to the 5.1.10 changelog: The DriverManager.getConnection() method ignored a non-standard port if it was specifiedin the JDBC connection string. Connector/J always used the standard port 3306 forconnection creation. For example, if the string was jdbc:mysql://localhost:6777,Connector/J would attempt to connect to port 3306, rather than 6777. 改設成3306一試就ok,用其他的port都是這個問題Orz 結論就是mysql的port乖乖設3306就好,不要耍帥設什麼5566、7788....etc -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 210.69.178.34

07/27 09:25, , 1F
你沒看清楚 mysql 官網,其實可以不用填資料 ~__~
07/27 09:25, 1F

07/27 09:28, , 2F
不用填嗎?囧
07/27 09:28, 2F

07/27 10:20, , 3F
不用= =
07/27 10:20, 3F

07/27 10:35, , 4F
不用填阿
07/27 10:35, 4F

07/27 19:58, , 5F
XDDD
07/27 19:58, 5F

07/27 20:39, , 6F
mysql的資料填寫是可以跳過的=.=
07/27 20:39, 6F

07/30 22:24, , 7F
之前我下載java的時候還也跑去填...後來有一天發現不用填XD
07/30 22:24, 7F

08/01 21:11, , 8F
你上了賊船了囧
08/01 21:11, 8F

08/12 00:22, , 9F
感謝~我也遇到這個問題 卡了一個晚上
08/12 00:22, 9F
文章代碼(AID): #1CJZE1If (java)