com.mysql.jdbc.MysqlDataTruncation:数据截断:列'column_name'的数据太长 [英] com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'column_name'

查看:121
本文介绍了com.mysql.jdbc.MysqlDataTruncation:数据截断:列'column_name'的数据太长的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有MySQL的Java JDBC,我收到此错误:

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'

如何解决此错误?

推荐答案

这看起来很明显,而且确实如此。您显然试图插入或更新一行,其中'column_name'列的值大于适合所述列的值。

This may seem pretty obvious, and it is. You apparently tried to insert or update a row with a value for the 'column_name' column that is larger than will fit into said column.

如果是CHAR或VARCHAR,则为例如,您可能有一个比列定义的大小更长的字符串。

If it's CHAR or VARCHAR, for example, you probably have a string that's longer than the defined size of the column.

您修复此选项的选择也有些明显 - 要么确保您的数据store不大于列(可能通过在存储它们之前截断更长的字符串),或者增加数据库列的大小。

Your choices for fixing this are also somewhat obvious - either make sure that the data that you store is no larger than the column (perhaps by truncating longer strings before storing them), or increase the size of the database column.

这篇关于com.mysql.jdbc.MysqlDataTruncation:数据截断:列'column_name'的数据太长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆