MySQL error: Specified key was too long; max key length is 767 bytes #455
Hi, I'm initializing repository this way:
however I get an error in the application:
When I try to run DDL separately in the database:
I get the same error..
As you do not specify encoding and my database used utf16_czech_ci collation, this maxed out allowed 767 bytes for a key size. After setting it to utf8_czech_ci, the problem went away.
The text was updated successfully, but these errors were encountered:
I guess it must have been this one:
property_name length is 200 x 4 bytes is 800 bytes for utf16
same goes for other tables. Just try to run it on InnoDB engine and utf16, you'll hit this error.
ok, so in MySql you can specify characterset for individual tables (i didn't know that). And if you don't specify characterset when crating a table, MySql will use db characterset. In your case it is utf16_czech_ci which breaks Javers' ddl's.
Feel free to create a Pull Request to PolyJDBC with a fix
Not sure if I have the same error or a different one, therefore I just take over this issue. Hope that is ok.
Here is my example program. Very simple. I just wanted to get started and set up a empty database. Therefore the root user. This is just for local development.
The default character set is already utf8. So the fix @vrozkovec suggests isn't working for me.
Must be related to commit 0804fb9. The size of the varchar column was increased from 200 to 600.
Ok, after some digging I think the problem is with create index and a missing prefix length.
If you call this with the mysql command line client it creates an index with a supart of 255. MySQL just assumes 3 bytes with UTF8. 3 times 255 makes 765 which is less than 767.
Unfortunately this does not work with plain JDBC connections. If you use a DDL statement through a jdbc driver it failes with the exception.
The solution to fix this to add a prefix length.
Unfortunately this is not possible with polyjdbc. I open a ticket and if I find the time PR.