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

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

數(shù)據(jù)庫(kù)連接報(bào)錯(cuò)Communications link failure

數(shù)據(jù)庫(kù)連接報(bào)錯(cuò)Communications link failure

二道橋十三太保 2017-03-16 17:55:49
package?util; import?java.sql.Connection; import?java.sql.DriverManager; public?class?DBHelper?{ private?static?final?String?driver="com.mysql.jdbc.Driver"; private?static?final?String?url="jdbc:mysql://localhost:3006/imooc"; private?static?final?String?username="root"; private?static?final?String?password="123456"; private?static?Connection?conn=null; //靜態(tài)代碼塊負(fù)責(zé)加載驅(qū)動(dòng) static{ try{ Class.forName(driver); }catch(Exception?ex){ ex.printStackTrace(); } } //單例模式返回?cái)?shù)據(jù)庫(kù)連接對(duì)象 public?static?Connection?getConnection()?throws?Exception{ if(conn==null){ conn=DriverManager.getConnection(url,?username,?password); return?conn; } return?conn; } //判斷連接是否成功 public?static?void?main(String[]?args)?{ try?{ Connection?conn=DBHelper.getConnection(); if(conn!=null){ System.out.println("數(shù)據(jù)庫(kù)連接正常"); }else{ System.out.println("數(shù)據(jù)庫(kù)連接異常"); } }?catch?(Exception?e)?{ //?TODO?Auto-generated?catch?block e.printStackTrace(); } } }代碼如上?請(qǐng)問(wèn)要怎么處理?
查看完整描述

1 回答

已采納
?
夢(mèng)影劍魂

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

?private?static?final?String?url="jdbc:mysql://localhost:3006/imooc";你把端口號(hào)改成3006了??如果沒(méi)有,默認(rèn)的應(yīng)該是3306

查看完整回答
反對(duì) 回復(fù) 2017-03-18
  • 1 回答
  • 0 關(guān)注
  • 3320 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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