`
southforest
  • 浏览: 22644 次
  • 性别: Icon_minigender_1
  • 来自: 福州
文章分类
社区版块
存档分类
最新评论

Data truncation: Data truncated for column异常的解决

阅读更多
从excel 读取数据插入mysql库中,
莫名其妙地少数几条记录的中文字段用程序插入不了,而用客户端写sql可以成功,用肉眼看没发现那几条记录数据有什么异常。
Error: 错误:basename=福×××× 口cellId_b=46错误原因: 
--- The error occurred in com/fsti/cdr/persistence/sqlmapdao/sql/ImportFile.xml. 
--- The error occurred while applying a parameter map. 
--- Check the insertCell-InlineParameterMap. 
--- Check the statement (update failed). 
--- Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data truncated for column 'BASENAME' at row 1
com.ibatis.common.jdbc.exception.NestedSQLException:  
--- The error occurred in com/fsti/cdr/persistence/sqlmapdao/sql/ImportFile.xml. 
--- The error occurred while applying a parameter map. 
--- Check the insertCell-InlineParameterMap. 
--- Check the statement (update failed). 
--- Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data truncated for column 'BASENAME' at row 1
Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data truncated for column 'BASENAME' at row 1
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:91)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.update(SqlMapExecutorDelegate.java:500)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.update(SqlMapSessionImpl.java:85)
at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.update(SqlMapClientImpl.java:62)
at com.fsti.cdr.service.ImportFileService.insertCell(ImportFileService.java:42)
at com.fsti.cdr.zte.parser.ExcelParser$1.run(ExcelParser.java:124)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data truncated for column 'BASENAME' at row 1
at com.mysql.jdbc.SQLError.convertShowWarningsToSQLWarnings(SQLError.java:758)
at com.mysql.jdbc.MysqlIO.scanForAndThrowDataTruncation(MysqlIO.java:3570)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2128)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2543)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1737)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:998)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:168)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:84)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteUpdate(GeneralStatement.java:200)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:78)
... 6 more

Caused by:
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data truncated for column 'BASENAME' at row 1
at com.mysql.jdbc.SQLError.convertShowWarningsToSQLWarnings(SQLError.java:758)
at com.mysql.jdbc.MysqlIO.scanForAndThrowDataTruncation(MysqlIO.java:3570)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2128)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2543)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1737)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:998)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:168)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:84)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteUpdate(GeneralStatement.java:200)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:78)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.update(SqlMapExecutorDelegate.java:500)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.update(SqlMapSessionImpl.java:85)
at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.update(SqlMapClientImpl.java:62)
at com.fsti.cdr.service.ImportFileService.insertCell(ImportFileService.java:42)
at com.fsti.cdr.zte.parser.ExcelParser$1.run(ExcelParser.java:124)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)

Caused by:
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data truncated for column 'BASENAME' at row 1
at com.mysql.jdbc.SQLError.convertShowWarningsToSQLWarnings(SQLError.java:758)
at com.mysql.jdbc.MysqlIO.scanForAndThrowDataTruncation(MysqlIO.java:3570)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2128)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2543)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1737)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:998)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:168)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:84)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteUpdate(GeneralStatement.java:200)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:78)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.update(SqlMapExecutorDelegate.java:500)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.update(SqlMapSessionImpl.java:85)
at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.update(SqlMapClientImpl.java:62)
at com.fsti.cdr.service.ImportFileService.insertCell(ImportFileService.java:42)
at com.fsti.cdr.zte.parser.ExcelParser$1.run(ExcelParser.java:124)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)

将字段改为varchar(255)和设置默认值都不能解决。其实中文值得程度没有超过255,不是长度不够引起。
将字段类型改为varbinary能解决上面的问题。
读取时要进行转换:convert(col using gb2312)
分享到:
评论

相关推荐

    MySQL中字符串与Num类型拼接报错的解决方法

    发现问题 图片地址如下 ...需要实现的效果是要加上尺寸,如以下效果 ...一开始想当然使用 UPDATE tag_group SET cover = cover + '|...Data truncation: Truncated incorrect DOUBLE value: ‘http://huoche.7234.cn/im

    mysql插入数据中文报错问题,最全解决方式

    ERROR SqlExceptionHelper:147 Incorrect string value: '\xE6\xB2\xA1\xE5\x90\x83' for column 'others' at row 1 org.springframework.orm.jpa.JpaSystemException: could not execute statement; nested ...

    Survival Analysis_Techniques for Censored and Truncated Data_Book

    本书《Survival Analysis: Techniques for Censored and Truncated Data》由John P. Klein和Melvin L. Moeschberger合著,第二版进一步扩展和完善了第一版的内容。 #### 二、删失与截尾的概念 **删失(Censoring)**...

    Mysql数据库乱码问题:Incorrect string value

    2. **解决乱码问题的步骤**: - **检查当前设置**:通过执行`status`命令查看MySQL的字符集配置。确保所有这些选项都是`utf8`,以支持广泛的语言,包括中文。 - **更改会话字符集**:如果发现非`utf8`字符集,可以...

    java中常见的错误.docx

    3. 数据类型不匹配:当尝试将不兼容的数据类型插入到数据库中时,如`Data truncated for column 'gatheringMoney' at row 1`和`Data truncation: Out of range value adjusted for column 'amount' at row 14`,表明...

    Data Truncation(亲测可用).md

    Data Truncation(亲测可用).md

    strings-truncation:用全角字符和ANSI代码截断字符串

    字符串::截断 使用全角字符和ANSI代码截断字符串。 特征 没有猴子修补String类 ... strings = Strings :: Truncation . new strings . truncate ( "I try all things, I achieve what I can." ) # => "I try all thing

    truncation:这个程序截断一个给定的数字-matlab开发

    在MATLAB编程环境中,`truncation`是一个常见的数学操作,用于处理浮点数,将它们转换为整数或者按照指定精度进行截断。在给定的标题和描述中,我们关注的是一个特定的MATLAB函数,即`truncate`,它用于截断一个给定...

    Mysql中文乱码问题完美解决方案.docx

    - `com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column` 错误表示数据长度超过了列的允许长度,这通常不是字符集问题,而是字段长度不足。需检查对应列的定义并调整其大小。 7. **...

    truncation:多边形的截断

    在IT领域,尤其是在Web开发中,SVG(Scalable Vector Graphics)是一种常用的技术,用于创建矢量图形。本文将深入探讨“截断”这一概念,特别是在多边形处理中的应用,以及如何使用React来实现SVG图标的构建。...

    ngx-line-truncation:角线截断解决方案。 通过给定的行号截断文本块,并在末尾添加省略号

    NGX线截断Ngx Line Truncation是Angular的行截断实现,可通过用户定义的行号截断文本。 () 除行截断外,此软件包还进行了一些性能优化,不仅提高了可用性,而且还提高了Angular平台的可靠性。 它使用重试逻辑来...

    MySQL关于sql_mode解析与设置讲解

    昨晚在往MySQL数据库中插入一组数据时,出错了!数据库无情了给我报了个错误:ERROR 1365(22012):Division by 0;意思是说:你不可以往数据库中插入一个 除数为0的运算的结果。于是乎去谷歌了一番,总算是明白了...

    sql server导入oracle数据库.rar

    在"SQLSERVER导入ORACLE数据库.pdf"中,可能详细介绍了上述步骤,包括如何配置这些工具,设置参数,以及解决可能遇到的问题。例如,可能涉及到ODBC驱动的配置,以便SQL Server能与Oracle通信,或者处理日期、时间戳...

    Missing and Modified Data in Nonparametric Estimation with R

    This book presents a systematic and unified approach for modern nonparametric treatment of missing and modified data via examples of density and hazard rate estimation, nonparametric regression, ...

    Image compression using modified block truncation coding

    图像编码,this paper presents a modified block truncation coding(BTC) algorithm for image compression.Similar block in an image are mergrd intoa cluster and represented with the cluster center.

    High performance reversible data hiding for block truncation coding compressed images

    Because most digital images are stored and transmitted in compressed forms, such as JPEG, vector quantization, and block truncation coding (BTC), the reversible data hiding schemes in compressed ...

    An efficient tensor completion method via truncated nuclear norm.pdf

    文章 "An efficient tensor completion method via truncated nuclear norm.pdf" 提出了一种基于截断核范数的张量补全方法,该方法通过优化截断核范数来实现张量数据的有效补全,并且包含了详细的理论推导和仿真实验...

    Applied Numerical Methods with MATLAB for Engineers and Scientists

    Title: Applied Numerical Methods with MATLAB for Engineers and Scientists, 4th Edition Author: Steven Chapra Length: 720 pages Edition: 4 Language: English Publisher: McGraw-Hill Education Publication...

Global site tag (gtag.js) - Google Analytics