Tuesday, January 24, 2017

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Column length too big for column 'published_value' (max = 65535); use BLOB or TEXT instead

Leave a Comment

I created a mysql database on my local mysql using the following command

alter database foo character set=latin1; 

I generated Tables.scala using the slick auto code generation against the production mysql database. I am now running the following code against my local database.

val targetUrl = s"jdbc:mysql://localhost:3306/foo? user=user&password=pass&jdbcCompliantTruncation=false" 

Now I execute the following code

val createAllTablesAction = Tables.schema.create val createAllTablesFuture = target.run(createAllTablesAction) val results = Await.result(createAllTablesFuture, Duration.Inf) 

But I get the following error

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Column  length too big for column 'foo_value' (max = 65535); use BLOB or TEXT instead     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)     at com.mysql.jdbc.Util.handleNewInstance(Util.java:389)     at com.mysql.jdbc.Util.getInstance(Util.java:372)     at com.mysql.jdbc.SQLError.createSQLException( 

I googled around and I found two solutions to this problem. One was to try the latin character set and the second was to use the jdbcCompliantTruncation to false. but both solutions did not work for me.

I also saw this issue in Slick github

https://github.com/slick/slick/issues/1070

it says the issue is fixed. I am using Slick 3.1.1 but I am still facing this issue. Here is my built.sbt

  val slickVersion = "3.1.1"   libraryDependencies ++= Seq(      "com.typesafe.slick" %% "slick" % slickVersion,      "com.typesafe.slick" %% "slick-codegen" % slickVersion,      "mysql" % "mysql-connector-java" % "5.1.35",      "com.typesafe" % "config" % "1.3.1"   ) 

I check the character set and colation of both the source and target databases

Prod: foo utf8 utf8_general_ci local: foo utf8 utf8_general_ci

So looks like both have the same character set and same collation.

Version of mysql:

prod: innodb_version 5.6.27-75.0 local: innodb_version 5.7.16

0 Answers

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment