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.