SQLException: Illegal mix of collations

293 views
Skip to first unread message

Murali T

unread,
Feb 16, 2011, 5:12:03 PM2/16/11
to Repo and Gerrit Discussion
hi all,

I'm getting exactly the same error described in this bug (closed as
'wont fix').

http://code.google.com/p/gerrit/issues/detail?id=435

I've checked the with my DBA and he said the setup was exactly as per
the documentation:

CREATE USER 'gerrit2'@'localhost' IDENTIFIED BY 'secret';
CREATE DATABASE reviewdb;
ALTER DATABASE reviewdb charset=latin1;
GRANT ALL ON reviewdb.* TO 'gerrit2'@'localhost';
FLUSH PRIVILEGES;

Is this still something needs to be changed on the server side or
Connector (Gerrig config) side? any pointer is greatly appreciated.

regards,
Murali T

Shawn Pearce

unread,
Feb 16, 2011, 7:55:16 PM2/16/11
to Murali T, Repo and Gerrit Discussion
On Wed, Feb 16, 2011 at 14:12, Murali T <k12m...@gmail.com> wrote:
> I'm getting exactly the same error described in this bug (closed as
> 'wont fix').
>
> http://code.google.com/p/gerrit/issues/detail?id=435
>
> I've checked the with my DBA and he said the setup was exactly as per
> the documentation:
>
> CREATE USER 'gerrit2'@'localhost' IDENTIFIED BY 'secret';
>  CREATE DATABASE reviewdb;
>  ALTER DATABASE reviewdb charset=latin1;

I wonder if you need to do this per-table in MySQL...

Rob Heittman

unread,
Feb 16, 2011, 8:18:59 PM2/16/11
to Shawn Pearce, Murali T, Repo and Gerrit Discussion
There's a connection string setting as well, something like

?useUnicode=false&characterEncoding=latin1

I haven't tried this exactly, as I'm usually in the situation of
specifying the opposite:

?useUnicode=true&characterEncoding=utf8

but I definitely get "illegal mix of collations" if my database is in
UTF-8 (usual, given our data sets) and the client's JDBC driver is
connecting with Latin-1 (as usually defaulted on Windows); I assume --
but don't know -- the reverse is also true. Not sure how one would
pass these settings thru the Gerrit properties ... ?

Shawn Pearce

unread,
Feb 16, 2011, 8:28:20 PM2/16/11
to Rob Heittman, Murali T, Repo and Gerrit Discussion
On Wed, Feb 16, 2011 at 17:18, Rob Heittman <heittm...@gmail.com> wrote:
> There's a connection string setting as well, something like
>
> ?useUnicode=false&characterEncoding=latin1
>
> I haven't tried this exactly, as I'm usually in the situation of
> specifying the opposite:
>
> ?useUnicode=true&characterEncoding=utf8
>
> but I definitely get "illegal mix of collations" if my database is in
> UTF-8 (usual, given our data sets) and the client's JDBC driver is
> connecting with Latin-1 (as usually defaulted on Windows); I assume --
> but don't know -- the reverse is also true. Not sure how one would
> pass these settings thru the Gerrit properties ... ?

You have to hand-craft the JDBC URL. I think there is an example in
the documentation in the database section.

Murali T

unread,
Feb 17, 2011, 2:18:13 AM2/17/11
to Repo and Gerrit Discussion
JDBC url did the trick and I'm not getting those nasty errors anymore.
Here is the URL I used in my gerrit.conf:

url = jdbc:mysql://mysqldb.xxx.xxx:3308/reviewdb?
user=gerrit123&password=secret123&useUnicode=false&characterEncoding=latin1

Many thanks to Shawn and Rob for the pointers!

regards,
-Murali T

On Feb 16, 5:28 pm, Shawn Pearce <s...@google.com> wrote:
Reply all
Reply to author
Forward
0 new messages