Breaking News
Home / Java / Java Issues / Data truncation: Data too long for column – JDBC

Data truncation: Data too long for column – JDBC

Issue

Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for columncolumname‘ at row 1
     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3595)
     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)
     at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990)
     at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151)
     at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2625)
     at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
     at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2415)
     at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2333)
     at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2318)
     at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
     at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
     at com.infuze.service.subscription.dao.SubscriptionDao.addSubscriptionTrail(SubscriptionDao.java:674)
     at com.infuze.service.subscription.workflow.SubscriptionAddonWorkflow.executeProcess(SubscriptionAddonWorkflow.java:100)
     … 10 more<!>

Answer

This JDBC exception means that the column that you are trying to update has been defined as smaller length in the database compared to length of the data that it is being updated with. There are 2 ways to resolve this. 

1- Increase the column length in database to accomodate that increased data length.

2- Add validation and truncate the data to limit to the database column length.

[pb_builder]

Check Also

Hibernate SQL Error: 904

Issue 2012-02-21 12:20:00,341[ExecuteThread: ’93’ for queue: ‘default’]DEBUG CustomerDAOFactory [#23640743#]-method : CustomerAttribDAO getCustomerAttributesDAO() 2012-02-21 12:20:00,341[ExecuteThread: ’93’ …

Advertisment ad adsense adlogger