Workaround by mysql and jdbc Chinese problem

xiaoxiao2021-03-06  73

Why didn't I delete this article I sent yesterday? !

To allow mysql to support Chinese, there are two ways: 1. When using JDBC, the URL should use this form: JDBC: mysql: // localhost: 3306 / test? Useunicate: 3306 / test? Useunicate = true & characterencoding = EUC_CN This method can have certain Loss, because of a certain conversion. And if it is used in Tomcat, the method is invalid. (I suspect that because other properties in the URL parameters of DBCP are invalid, other connection properties can only be configured inside ConnectionProperties, but DBCP's documentation is not clear to ConnectionProperties. 2, add default-character-set = GBK below my.ini, then the URL of the Java end does not need to add parameters such as Useunicode, or can process Chinese normally. The problem that should be paid is that if this method is used by MySQL-Connector-Java-3.0.11-stable-bin.jar driver, the following error occurs: Error: java.sql.sqlexception: Error During query: UNEXPECTED EXCEPTION : java.lang.stringindexoutofboundsexception Message Given: String Index Out of Range: 40 ... Using mysql-connector-java-3.1.2-alpha-bin.jar with mysql-connector-java-3.1.3-beta-bin.jar Can work normally.

转载请注明原文地址:https://www.9cbs.com/read-121157.html

New Post(0)