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 ...
随机推荐
- iOS官方文档阅读 基本格式指北
一些关键词作用 NS_AVAILABLE 表示可用 如 NS_AVAILABLE(NA, 6_0);例如上面这句就是表示 该方法在6.0系统后可用 如果在6.0以下的系统用不了的 或者直接崩溃. NS ...
- DotNet Core 2.0使用MySql实现Code First
本教程使用vs2017 + dotnet core2.0 + MySql5.7.19 1.打开vs2017,文件>新建>项目,选择Asp.Net Core Web应用程序. 2.项目名称可 ...
- centos 搭建 搭建uwsgi服务
1. 安装linux系统所需的一些软件依赖 yum groupinstall "Development tools" yum install openssl openssl-dev ...
- C++ vector 和 map的删除
1.连续内存序列容器(vector,string,deque) 序列容器的erase方法返回值是指向紧接在被删除元素之后的元素的有效迭代器,可以根据这个返回值来安全删除元素. vector<in ...
- 高性能网络 | 你所不知道的TIME_WAIT和CLOSE_WAIT
你遇到过TIME_WAIT的问题吗? 我相信很多都遇到过这个问题.一旦有用户在喊:网络变慢了.第一件事情就是,netstat -a | grep TIME_WAIT | wc -l 一下.哎呀妈呀 ...
- Eclipse上Hadoop插件中Run On Hadoop原理[转]
通过Eclipse的hadoop插件中的"run on hadoop"命令的原理:它不是把jar包发送到hadoop集群上去运行,而只是使用了hadoop集群上的hdfs,从hdf ...
- 浅析StackTrace
我们在学习函数调用时,都知道每个函数都拥有自己的栈空间.一个函数被调用时,就创建一个新的栈空间.那么通过函数的嵌套调用最后就形成了一个函数调用堆栈.在c#中,使用StackTrace记录这个堆栈.你可 ...
- 应有dataGridView控件
using System.Data.SqlClient; namespace UseDataGridView { public partial class Form1 : Form { public ...
- 连接数据库通过配置文件app.config
ConfigurationManager类 public static class ConfigurationManager 命名空间: System.Configuration 程序集: Syste ...
- sama5 kio接口控制
//example #include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <str ...