第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

用JDBC和MySQL解決“通信鏈路故障”

用JDBC和MySQL解決“通信鏈路故障”

慕哥9229398 2019-05-31 16:51:37
用JDBC和MySQL解決“通信鏈路故障”我試圖連接到本地MySQL服務(wù)器,但是我一直收到一個(gè)錯(cuò)誤。這是密碼。public class Connect {     public static void main(String[] args) {         Connection conn = null;         try {             String userName = "myUsername";             String password = "myPassword";             String url = "jdbc:mysql://localhost:3306/myDatabaseName";             Class.forName("com.mysql.jdbc.Driver").newInstance();             conn = DriverManager.getConnection(url, userName, password);             System.out.println("Database connection established");         } catch (Exception e) {             System.err.println("Cannot connect to database server");             System.err.println(e.getMessage());             e.printStackTrace();         } finally {             if (conn != null) {                 try {                     conn.close();                     System.out.println("Database Connection Terminated");                 } catch (Exception e) {}             }         }     }}還有錯(cuò)誤:Cannot connect to database serverCommunications link failureThe last packet sent successfully to the server was 0  milliseconds ago.  The driver has not received any packets from the server.com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications  link  failureThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets   from the server.         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)         at java.lang.reflect.Constructor.newInstance(Constructor.java:513)         at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)我已經(jīng)設(shè)置了類路徑,確保我的.cnf將跳轉(zhuǎn)網(wǎng)絡(luò)選項(xiàng)注釋掉。Java版本為1.2.0_26(64位)MySQL 5.5.14 MySQL連接器5.1.17我確保用戶能夠訪問我的數(shù)據(jù)庫。
查看完整描述

3 回答

?
慕碼人8056858

TA貢獻(xiàn)1803條經(jīng)驗(yàn) 獲得超6個(gè)贊

如果你正在使用MamPpro,簡單的修復(fù),我真的希望我已經(jīng)意識(shí)到之前,我開始搜索互聯(lián)網(wǎng)數(shù)天試圖找出這一點(diǎn)。真的這么簡單.。

您只需單擊MamPMySQL選項(xiàng)卡中的“允許網(wǎng)絡(luò)訪問MySQL”即可。

真的,就是這樣。

哦,您可能仍然需要將綁定地址更改為0.0.0.0或127.0.0.1,就像上面的文章所概述的那樣,但是如果您是MamP用戶,單擊該框可能會(huì)解決您的問題。


查看完整回答
反對 回復(fù) 2019-05-31
?
料青山看我應(yīng)如是

TA貢獻(xiàn)1772條經(jīng)驗(yàn) 獲得超8個(gè)贊

設(shè)置bind-address到服務(wù)器的網(wǎng)絡(luò)IP上,而不是本地主機(jī)默認(rèn)設(shè)置,并對我的用戶設(shè)置特權(quán)為我工作。

我的.cnf:

bind-address = 192.168.123.456

MySQL控制臺(tái):

GRANT ALL PRIVILEGES ON dbname.* to username@'%' IDENTIFIED BY 'password';


查看完整回答
反對 回復(fù) 2019-05-31
  • 3 回答
  • 0 關(guān)注
  • 2193 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)