com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'column_name'

thilo picture thilo · Nov 26, 2012 · Viewed 81.6k times · Source

I am using Java JDBC with MySQL and I get this error:

com.mysql.jdbc.MysqlDataTruncation: Data truncation: 
Data too long for column 'column_name'

How do I remedy this error?

Answer

Vijay Gajera picture Vijay Gajera · Jun 4, 2017

I faced same issue in my spring boot data jpa application when i going to insert image file in data base as byte its given me same error.

After many R & D i found solution like below.

I added below line in my application.properties file and resolve that

spring.datasource.url=jdbc:mysql://localhost:3306/conweb?sessionVariables=sql_mode='NO_ENGINE_SUBSTITUTION'&jdbcCompliantTruncation=false

Hope it will helpful to someone.