6 Replies Latest reply on Mar 4, 2005 2:04 PM by czernay

    MySQL 4.1: Specified key was too long; max key length is 102

    czernay Newbie

      There seems to be a problem with MySQL 4.1 and JBoss 4.01 (using mysql-connector-java-3.1.6-bin.jar) when creating a CMR-many-to-many-relationship table. I have two simple CMP-beans that I try to connect via a relation-table. The beans both have a simple String primary key that is set to be VARCHAR(250) BINARY for MySQL as JBoss's standard.

      This configuration gives me a SQL statement like this:
      CREATE TABLE Image2Author (author_id VARCHAR(250) BINARY NOT NULL, image_id VARCHAR(250) BINARY NOT NULL, CONSTRAINT pk_Image2Author PRIMARY KEY (author_id, image_id))

      and an error like this:
      Error while creating table Image2Author; - nested throwable: (java.sql.SQLException: Specified key was too long; max key length is 1024 bytes)

      I reduced the standard String setup to a VARCHAR(190) BINARY and it also didn't work. However, a setup with a VARCHAR(100) BINARY worked, but that seems to be a rather nasty workaround.

      I also played around with the MySQL setup to support UTF-8 or not, but that didn't make any difference.

      Is there anything one could do to fix this? Any ideas?