在EJB

2012-05-16 75 views
0

歸類在MySQL 5.1的latin1_general_ci數據庫歸類的非法搭配,我得到這個例外,當我UPDATE在EJB

 
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.DatabaseException 
Internal Exception: java.sql.SQLException: Illegal mix of collations (latin1_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '=' 
Error Code: 1267 
Call: 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.ConsultantId AND medicaltestdetails.TestTime = TL_medicaltestdetails.TestTime 
Query: 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))") 

請幫我解決這個問題。

+0

請展後的'輸出CREATE TABLE'兩個'medicaltestdetails'和'TL_medicaltestdetails'。 – eggyal

回答

4

您可能在我的JDBC連接字符串中添加了'& characterEncoding = UTF-8'。 如果

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 

盧卡

+0

謝謝。你是我發現的第一個答案,強調錶中的列可以有自己的編碼(不管表的默認編碼)。 – Jason