如何在MySQL终端中重现此错误
mysql> create table penguins(val CHAR(2));
Query OK, 0 rows affected (0.08 sec)
mysql> insert into penguins values("AB");
Query OK, 1 row affected (0.00 sec)
mysql> insert into penguins values("ABC");
Query OK, 1 row affected, 1 warning (0.01 sec)
mysql> show warnings;
+---------+------+------------------------------------------+
| Level | Code | Message |
+---------+------+------------------------------------------+
| Warning | 1265 | Data truncated for column 'val' at row 1 |
+---------+------+------------------------------------------+
1 row in set (0.00 sec)
这是您收到的错误,但是在MySQL终端中将其显示为警告,并且仍然插入您的行,只是静默地截断它。
MySQL JDBC不那么宽容,并且吐出一个硬错误并且不会插入行。
2 解决方案
增加要插入的数据类型的容量,或减小要放置在其中的内容的大小。
增加列大小的图例:
If you are using then use this
----------------- --------------
smallint int
int long
TEXT LONGTEXT
LONGTEXT CLOB
CLOB Store the content to disk, and save the filename in the db.