1.初学java链接数据库,出现
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
怀疑是数据库没链接成功!
查看eclispe端口号为3306,于是查看mysql的端口号,终端输入:
show global variables like 'port';
后显示:
image.png
果然不是3306 于是决定修改方法为
1.停止MySQL服务
2.在com.oracle.oss.mysql.mysqld.plist文件中的ProgramArguments下添加--port=3306保存退出
这里直接修改可能会提示没有权限
3.打开终端输入cd 到com.oracle.oss.mysql.mysqld.plist所在目录
输入
sudo vim com.oracle.oss.mysql.mysqld.plist
编辑为如下图
image.png
保存
重启mysql