com.mysql.jdbc.MysqlDataTruncation: Data truncation异常

Exception in thread "main" com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column ‘note‘ 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:1169)
at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:693)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1404)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1318)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1303)
at MyPrepare.main(MyPrepare.java:87)

原因:

第一,方法重载问题

第二,字符超过了长度

第三,就是编码问题(重要,容易被人忽略)

有两种可能,第一种就是数据库编码,另外一种数据库编码没问题,文件编码有问题

原文地址:https://www.cnblogs.com/qingmuchuanqi48/p/11747033.html

时间: 2024-11-05 16:00:16

com.mysql.jdbc.MysqlDataTruncation: Data truncation异常的相关文章

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 work at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:69) at org.hibernate.exception.internal.Stand

mysql 插入中文报错: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value...

总结写在前面, 总结: 当Java通过jdbc链接mysql插入中文时,要保证程序可以正常执行,而且插入的中文不会乱码, mysql服务器端,对数据表(不是数据库)的编码设置,要保证是支持中文的,例如gbk, gb2312, utf-8 jdbc的连接配置,要开启useUnicode=true,并且要设置一个支持中文的编码,不需要跟mysql表的编码保持一致,只需要支持中文就行.例如characterEncoding=utf8 本身的Java文件的编码需要支持中文 ===============

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.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:69) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert

Caused by com mysql jdbc MysqlDataTruncation Data truncati

1.错误描述 [ERROR:]2015-06-08 09:49:42,523 [异常拦截] org.hibernate.exception.DataException: error executing work at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:69) at org.hibernate.exception.internal.Stand

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 exceptiocom.mysql.jdbc.MysqlDataTruncation: Data truncation: Data to

Cause: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Incorrect date value

Cause: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Incorrect date value: '1541123218569' for column 'create_time' at row 1 遇到这种问题的原因有两种 1.可能是表中设置的字符集与你想要插入的字符集不相同. 解决方法: (1)修改数据库默认编码ALTER DATABASE `test` DEFAULT CHARACTER SET u

Mysql JDBC Url参数与异常问题

今天在写Java项目使用了 <select id="getPlans" parameterType="hashMap" resultType="hashMap">         SELECT             *         FROM             `plan`         WHERE             isDelete=#{isDelete} AND nestId in              &l

ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] - Data truncation: Incorrect datetime value: &#39;&#39; for column &#39;pubdate&#39; at row 1

之前的Connector/J版本是:mysql-connector-java-5.0.4-bin.jar 后来换成mysql-connector-java-5.1.45-bin.jar,问题解决 2018-02-16 01:07:10,086 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] - SQL Error: 0, SQLState: 220012018-02-16 01:07:10,086 ERROR [org.hibern

Mybatis Data truncation: Truncated incorrect DOUBLE value: &#39;*&#39;

具体异常信息如下: org.springframework.dao.DataIntegrityViolationException: ### Error querying database. Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: '*' 错误代码如下: 解决办法: 在mybatis中的遇到这种拼接的情况,应该使用concat函数 数据库用的是mys