Com.mysql.jdbc.MysqlDataTruncation:Data Trunca ...

Source: Internet
Author: User

Connected to the MySQL database, when inserting data, the console report:

Com.mysql.jdbc.MysqlDataTruncation:Data Truncation:data too long for column ' user_name ' at row 1
Error, specific information is as follows:

Critical: 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)
........................

Look at this error message, how to have the feeling of déjà vu. But I just can't remember. According to the literal meaning, one is the input out of range. But my user_name field is set to varchar (45), only three Chinese are entered, how can it be exceeded?

Google, a look at the character set word, suddenly think of the past encountered this problem. Just early to the Cloud nine.

The reason: When the table is built, the table encoding and field encoding are the default latin1, set to UTF8, the problem is resolved.

As the saying goes, people can not step into the same river two times, I counted precepts.

(Transferred from: http://my.oschina.net/smile622/blog/106143)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.