com.mysql.jdbc.MysqlDataTruncation:Data Truncation:Data too long for column '字段name' at row 1
1.问题描述:
在mysql插入数据的时候报错:Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'xxx_name' at row 1
严重: Servlet.service() for servlet default threw exceptio
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'xxx_name' at row 1
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2868)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1160)
at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:685)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1400)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1314)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1299)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:745)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:538)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:739)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:797)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:805)
at com.bester.blog.dao.impl.UserDAOImpl.add(UserDAOImpl.java:25)
at com.bester.blog.service.impl.UserServiceImpl.add(UserServiceImpl.java:12)
at com.bester.blog.web.action.UserAction.add(UserAction.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
2.问题分析:
从字面意思看,是字段长度不够。即使设置为了text还是不够,因为text类型是可变长度的字符串,最多65535个字符,所有,最好是把字段类型设置为longtext,最多存放4294967295个字符
步骤:进入mysql,use你要改变的数据库,执行语句:alter table testTable modify column xxx_name longtext;
重启mysql,linux下语句:service mysqld restart
但是,我的xxx_name字段设置的是varchar(50),而输入的没几个字;
原因在于:建表的时候,表的编码和字段编码都是默认的latin1,设置为utf8后,问题解决。修改utf-8编码
com.mysql.jdbc.MysqlDataTruncation:Data Truncation:Data too long for column '字段name' at row 1的更多相关文章
- mysql 插入中文报错: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value...
总结写在前面, 总结: 当Java通过jdbc链接mysql插入中文时,要保证程序可以正常执行,而且插入的中文不会乱码, mysql服务器端,对数据表(不是数据库)的编码设置,要保证是支持中文的,例如 ...
- Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: 'L
1.错误叙述性说明 [ERROR:]2015-06-08 09:49:42,523 [异常拦截] org.hibernate.exception.DataException: error execut ...
- Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: 'L
1.错误描述 [ERROR:]2015-06-08 09:49:42,523 [异常拦截] org.hibernate.exception.DataException: error executing ...
- Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'content' a
1.错误描述 org.hibernate.exception.DataException: could not execute statement at org.hibernate.exception ...
- Error updating database. Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: 'as3'
执行更新时的出错信息 Whitelabel Error Page This application has no explicit mapping for /error, so you are see ...
- Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'img' at row 1故障
Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'img' at ro ...
- 数据库报错com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'ua' at row 1
记一次报错记录,成长路上的点滴 明明使用浏览器或者微信开发工具调试接口没有问题,但是在真机测试时候就出问题了.(((¬_¬)) 500服务器内部错误,要死的节奏啊 登陆tomcat服务器 使用命令ta ...
- com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value:...
在使用mybatis的@Update注解的时候,报了一个这样的错 ### Error updating database. Cause: com.mysql.jdbc.MysqlDataTruncat ...
- Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '' for column 'createtime' at row 1...
之前项目一直好好的,之后电脑重装系统,数据库重新安装了一个5.6版本的,项目jar包丢失了,之后就又重新找了一些jar包倒入,结果运行报错: Caused by: com.mysql.jdbc.Mys ...
随机推荐
- Spatial convolution
小结: 1.卷积广泛存在与物理设备.计算机程序的smoothing平滑.sharpening锐化过程: 空间卷积可应用在图像处理中:函数f(原图像)经过滤器函数g形成新函数f-g(平滑化或锐利化的新图 ...
- linux 将同后缀名的文件统一移至另一个文件夹
w
- FW:主流RPC框架
主流RPC框架 2015年10月27日 zman RPC 介绍目前在互联网公司比较流行的开源的RPC框架. RPC框架比较 语言 协议 服务治理 社区 机构 Hessian 多语言 he ...
- SNORT--install ---dependency-resolve
# ./configure 遇到ERROR: checking for pfring_open in -lpcap... no ERROR! Libpcap library/headers (lib ...
- 网络模型一般是指 OSI 七层参考模型和 TCP/IP 五层参考模型。
网络模型一般是指 OSI 七层参考模型和 TCP/IP 五层参考模型. 每一层实现各自的功能和协议,并且都为上一层提供业务功能.为了提供这 种业务功能,下一层将上一层中的数据并入到本层的数据域中,然后 ...
- CF#301 B:School Marks(贪心)
B:School Marks 有n个测试,已经完成了k个,每个测试得分为a[i],接下来的分数不知道,让我们求出任何一个满足题意的即可,满足题意就是n个测试的得分总和<=x, 中位数>=y ...
- Python并行编程(八):with语法
1.基本概念 当有两个相关的操作需要在一部分代码块前后分别执行的时候,可以使用with语法自动完成.同时,使用with语法可以在特定的地方分配和释放资源,因此,with语法也叫作"上下文管理 ...
- Redis for Python开发手册
redis基本命令 String Set set(name, value, ex=None, px=None, nx=False, xx=False) 在Redis中设置值,默认,不存在则创建,存在则 ...
- git学习------>从SVN迁移到Git之后,项目开发代码继续在SVN提交,如何同步迁移之后继续在SVN提交的代码到Git?
最近逐步逐步的将公司的项目都从SVN往Git迁移了,但是想团队成员都能够一步到位就迁移到Git是不可能的,因为还有大部分人都还不会Git,所以整个过渡过程估计得大半年. 因此导致虽然项目迁移过来了,但 ...
- 一次因为文件名开头包含空格而导致FTP文件一直无法下载的悲剧!
最近负责公司研究新的多渠道打包方案,之前的打包方案太慢了,因此采用了美团的Android Signature V2 Scheme签名下的新一代渠道包打包神器 方案进行了多渠道打包.但是由于马虎,在配置 ...