mysql begin nested exception,Java2MySQL>由于基础异常再次发生通信链路故障

I'm making program in Java, which connects to MySQL database. As first class was class with single static method returning java.sql.Connection. After it was debugged and connection was working I never touch it again. And few days ago I discovered my program was returning this error:

com.mysql.jdbc.CommunicationsException:

Communications link failure

due to underlying exception

BEGIN NESTED EXCEPTION

com.mysql.jdbc.CommunicationsException

MESSAGE:

Communication link

failure due to underlying exception:

BEGIN NESTED EXCEPTION

java.io.EOFException MESSAGE: Can not read response from server.

Expected 4 bytes, read 0 before connection was unexpectedly lost.

STACKTRACE:

...

I installed MySQL Server v. 5.1.62

I'm using MySQL/J connector v. 5.0.8 (downloaded from mysql.com)

also I put in classpath in NetBeans sqljdbc4.jar

Thing I can't understand is fact I didn't change user name and password on my localhost since I created my database. Only thing I changed are: add more tables and changed columns in tables, but that would not trigger this error. And thing I did with my project is I changed charset from UTF-8 to UTF-16, but I guess it hardly can affect my connection method.

If I change connector and put in classpath connector v. 5.1.22 it returns error:

Access denied for user "root@localhost" (using password: YES)

even I declared all privileges for user root.

解决方案

I will recommend following:

Firstly confirm if network is fine between two servers: a. ping from your server to your database server. b. use MTR unix tool to

ensure connectivity between two servers.

Are you using connection pool ? If yes, then try to restart the server. Probably few of the connections in your connection pool are in

closed state.

Lets firstly resolve the first issue. Other issue Access denied for user "root@localhost" (using password: YES) is an independent issue which we can discuss later.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值