Some error reporting issues using JDBC link to MySQL


English version steps

  • Encounter an error:
java.sql.SQLException: Unknown initial character set index ‘255‘ received from server.

You need to add after the database name of the URL you specify for MySQL:

?useUnicode=true&characterEncoding=utf8

which is:

jdbc:mysql://localhost:3306/YourDatabaseName?useUnicode=true&characterEncoding=utf8

where:

&

is the way it is written in XML, because XML cannot parse “&”

  • When you use an external property file, you need to remove the “amp;”, which means you can write “&” directly:
jdbc:mysql://localhost:3306/YourDatabaseName?useUnicode=true&characterEncoding=utf8

中文步骤

  • 遇到报错:
java.sql.SQLException: Unknown initial character set index ‘255‘ received from server.

需要在你指定的MySQL的URL的数据库名后增加:

?useUnicode=true&characterEncoding=utf8

也就是:

jdbc:mysql://localhost:3306/YourDatabaseName?useUnicode=true&characterEncoding=utf8

其中:

&

是XML中的写法,因为XML无法解析“&”

  • 当你使用外部属性文件时,则需要去除“amp;”也就是直接写“&”即可
jdbc:mysql://localhost:3306/YourDatabaseName?useUnicode=true&characterEncoding=utf8

Author: Anti-General
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint policy. If reproduced, please indicate source Anti-General !
R
Comment
  TOC