Search code examples
mysqlsqlconnector-j

Illegal mix of collations for simple stored procedure


I am attempting to run a stored procedure from Java using Connector/J on a MySQL server (5.5.23). The proc is

CREATE DEFINER = `[deleted]`@`localhost` PROCEDURE `GETGROUP` 
( IN `uname` CHAR( 16 ) CHARSET latin1 ) NOT DETERMINISTIC READS SQL DATA SQL 
SECURITY DEFINER SELECT `group` FROM `user` WHERE `username` = uname

However, it errors out with

java.sql.SQLException: Illegal mix of collations (latin1_general_ci,IMPLICIT) 
and (latin1_swedish_ci,IMPLICIT) for operation '='"

I am using latin1_general_ci exclusively throughout my database, so I have no clue what's going on.


Solution

  • You can force uname to use latin1_general_ci if you wish by adding COLLATE latin1_general_ci to the end of its declaration.