com.mysql.jdbc.MysqlDataTruncation: Data trunca...
连接的是mysql数据库,插入数据时,控制台报:
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'user_name' at row 1
错误,具体信息如下:
严重: Servlet.service() for servlet default threw exceptio
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'user_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)
........................
看着这错误信息,怎么有似曾相识的感觉呢。但就是记不起来了。根据字面意思,一位是输入超出范围了。但我的user_name字段设置的是varchar(45),只输入了三个中文,怎么可能超出呢?
google一下,一看到字符设置字眼,忽然想起以前碰到过这个问题的。只是早以到了九霄云外罢了。
原因在于:建表的时候,表的编码和字段编码都是默认的latin1,设置为utf8后,问题解决。
俗话说,人不能两次踏入同一条河流,我算破戒了。
(转自:http://my.oschina.net/smile622/blog/106143)
com.mysql.jdbc.MysqlDataTruncation: Data trunca...的更多相关文章
- 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 ...
- 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 fo ...
随机推荐
- 【微信小程序】request请求POST提交数据,记得要加上header
wx.request({ url: '*******', data: { "type":"nearest_village", "district&qu ...
- Ubuntu桌面操作快捷键
Ubuntu操作基本快捷键 * 打开主菜单 = Alt + F1 * 运行 = Alt + F2 * 打开终端 = Alt+F2 然后输入gnome-terminal回车 * 显示桌面 = Ctrl ...
- JAVA中的static方法
static表示“全局”或者“静态”的意思,用来修饰成员变量和成员方法,也可以形成静态static代码块,但是Java语言中没有全局变量的概念. 被static修饰的成员变量和成员方法独立于该类的任何 ...
- spring in action 5.1 小结 spring mvc起步
0 配置 DispatcherServlet 是 spring mvc的核心,常规配置方法可以查看之前博客.springMVC简单例子 在此使用servlet 3 规范和 spring3.1 功能增强 ...
- centos x64 vsftpd 530登陆错误问题
近来在centos 6.0 x64版本下安装vsftpd,中间出现一些问题,解决过程总结如下: 安装vsftpd:yum install vsftpd 安装后配置为虚拟用户登陆,然后用:ftp loc ...
- Java数据结构和算法(二):数组
上篇博客我们简单介绍了数据结构和算法的概念,对此模糊很正常,后面会慢慢通过具体的实例来介绍.本篇博客我们介绍数据结构的鼻祖——数组,可以说数组几乎能表示一切的数据结构,在每一门编程语言中,数组都是重要 ...
- [svc]visio绘制模具
visio2016狮子XL自定义运维模具下载: https://github.com/lannyMa/scripts/blob/master/%E7%BE%8E%E5%8C%96%E5%AE%9A%E ...
- PHP.ini中配置屏蔽错误信息显示和保存错误日志
在PHP程序运行过程中如果有错误发生,在浏览器上是否显示错误信息,以及显示错误信息的级别是我们在程序开发.调试.运营过程中需要控制的. root@(none):/alidata/www/default ...
- [linux]signal函数不起作用
#include "apue.h" #include <sys/wait.h> static void sig_int(int); /* our signal-catc ...
- Python中import和from import
Python里面的import和from import都是用于导入一个模块,两者的区别是 如果你在使用某模块内函数时不想写模块名,那么就用from import方式导入,如果是用import方式就要写 ...