JDBC connection to MySQL problem resolution
Recently, a series of problems occurred while configuring JDBC to connect to MySQL. Fortunately, it all worked out in the end. Here is a summary of the problems, hoping to help others with the same problems.
BlueStragglers shares the joy of technology growth
directory
A JDBC connection to MySQL analytical error: com.mysql.jdbc.exceptions.jdbc4.Com municationsException: Communications link failure2. Unknown initial character set index ‘255’ received from server.Initial client character3. Error: references to the entity ‘characterEncoding’ must begin with ‘; ‘End of delimiter 4. Reference content
1. An error: com.mysql.jdbc.exceptions.jdbc4.Com municationsException: Communications link failure
This problem is most likely due to a problem with the mysql-connector-java version of the pom.xml file. I started with version 5.1.44 and found that I kept reporting this error. This issue can be resolved by returning 5.1.6.
Of course, there is another case where this error is reported: MySQL Server will automatically disconnect and report an error if the connection takes more than 8 hours. The solution is usually to modify the configuration file.
Unknown initial character set index ‘255’ received from server.Initial client character
This problem is generally caused by the occurrence of Chinese in MySQL, which can not be properly resolved. The solution is to put a UTF8 encoding requirement at the end of the URL to avoid errors. For example, the source statement is:
<property name="url" value="jdbc:mysql://10.201.0.27:3307/mybatis"/>
This can be modified to the following statement:
<property name="url" value="jdbc:mysql://10.201.0.27:3307/mybatis?useUnicode=true&characterEncoding=utf8"/>
3. Error: references to the entity ‘CharacterEncoding’ must begin with ‘; ‘End of the delimiter
Encounter this problem, I am quite surprised, actually is Chinese report error. It was later discovered that MySQL had a problem with characterEncoding= UTF8, so it may have been for this reason that the error was reported in Chinese.
&
&
instead. For example, the following statement:
<property name="url" value="jdbc:mysql://localhost:3306/mybatis?useSSL=true&characterEncoding=utf8" />
The above statement will report an error. If you need to modify it to the following statement, it will not report an error:
<property name="url" value="jdbc:mysql://localhost:3306/mybatis?useSSL=true&characterEncoding=utf8" />
4. References
- JDBC connection to MySQL references to the entity 'CharacterEncoding' must begin with '; 'End of delimiter
Read More:
- Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure (How to Fix)
- How to Fix Exception in thread “main“ com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications
- java.lang.AbstractMethodError:com.mysql.jdbc.Connection.isValid(I)Z
- solve com.mysql.jdbc . exceptions.jdbc4 .MySQLSyntaxErrorException:
- JDBC connection to Oracle: listener used the connection with the following error: ora-12505
- When executing hive – f script com.mysql.jdbc . exceptions.jdbc4 .CommunicationsException: Communications link failure
- Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communicat
- java.lang.ClassNotFoundException : com.mysql.jdbc . driver project cannot connect to database, exception, lack of MySQL driver
- Failed to obtain JDBC Connection
- MySQL local connection Error 1130_ The solution of MySQL 1130 error report when remote connection through Navicat for MySQL
- In the XML configuration file of spring jdbc.properties The connection to the database failed due to garbled code
- How to solve the problem of “08001” when JDBC connects to MySQL
- MySQL Workbench: Error Code: 2013. Lost connection to MySQL server during query solution
- MySQL: if the remote connection using navicatip fails, prompt “is not allowed to connect to this MySQL server”
- JDBC connect to Sql Server to connect to the database–The TCP/IP connection to the host localhost, port 1433 has failed
- PHP connection to MySQL database error: call to undefined function MySQL_ connect()
- Loading class `com.mysql.jdbc.Driver‘. This is deprecated. The new driver class is `com.mysql.cj.jdb
- How to Fix Node.js connection to MYSQL error.
- Solutions to errors in the final running of JDBC programming
- 【Exception】mysqldump: Error 2013: Lost connection to MySQL server during query when dumping table…