0

在具有数据库排序规则的 MySQL 5.1 上latin1_general_ci,当我UPDATE

异常 [EclipseLink-4002] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.DatabaseException
内部异常:java.sql.SQLException:排序规则(latin1_general_ci,IMPLICIT)和(latin1_swedish_ci,IMPLICIT)的非法混合操作'='
错误代码:1267
调用: UPDATE medicaltestdetails, TL_medicaltestdetails SET medicaltestdetails.Status = TL_medicaltestdetails.Status WHERE medicaltestdetails.TestDate = TL_medicaltestdetails.TestDate AND medicaltestdetails.TestSerial = TL_medicaltestdetails.TestSerial AND medicaltestdetails.ConsultantId = TL_medicaltestdetails.Consultant_medicaltestdetails.TestTime
查询:UpdateAllQuery(referenceClass=Medicaltestdetails sql="CREATE TEMPORARY TABLE IF NOT EXISTS TL_medicaltestdetails (Chg BIGINT, Remarks VARCHAR(255), Result VARCHAR(255), Status VARCHAR(255), TestDesc VARCHAR(255), TestType VARCHAR(255) , TestDate DATE NOT NULL, TestSerial VARCHAR(255) NOT NULL, ConsultantId VARCHAR(255) NOT NULL, TestTime INTEGER NOT NULL, PRIMARY KEY (TestDate, TestSerial, ConsultantId, TestTime))")

请帮我解决这个问题。

4

1 回答 1

4

您可能已将 '&characterEncoding=UTF-8' 添加到我的 JDBC 连接字符串中。如果

mysql> show variables like "collation_database";
    +--------------------+-----------------+
    | Variable_name      | Value           |
    +--------------------+-----------------+
    | collation_database | utf8_general_ci |
    +--------------------+-----------------+

不是那样的

mysql> show table status;
    +--------------+-----------------+
    | Name         | Collation       |
    +--------------+-----------------+
    | my_view      | NULL            |
    | my_table     | utf8_unicode_ci |
    ...

不是那样的

做:

ALTER DATABASE mydb DEFAULT COLLATE utf8_unicode_ci;

并更改字段的编码:

ALTER TABLE my_table MODIFY COLUMN my_column column_type CHARACTER SET utf8 COLLATE utf8_unicode_ci [NOT NULL];

或更改表的编码:

ALTER TABLE my_table CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci

再见

卢卡

于 2012-08-20T13:46:11.700 回答