1.初學(xué)java鏈接數(shù)據(jù)庫,出現(xiàn)
com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@3f72acc1 --
Acquisition Attempt Failed!!! Clearing pending acquires.
While trying to acquire a needed new resource, we failed to succeed more than
the maximum number of allowed acquisition attempts (30). Last acquisition
attempt exception:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
懷疑是數(shù)據(jù)庫沒鏈接成功!
查看eclispe端口號(hào)為3306,于是查看mysql的端口號(hào),終端輸入:
show global variables like 'port';
后顯示:

image.png
果然不是3306 于是決定修改方法為
1.停止MySQL服務(wù)
2.在com.oracle.oss.mysql.mysqld.plist文件中的ProgramArguments下添加<string>--port=3306</string>保存退出
這里直接修改可能會(huì)提示沒有權(quán)限
3.打開終端輸入cd 到com.oracle.oss.mysql.mysqld.plist所在目錄
輸入
sudo vim com.oracle.oss.mysql.mysqld.plist
編輯為如下圖

image.png
保存
重啟mysql