-1

i'm trying to configure a jaspersoft report at jaspersoft server. I created a report that executes an stored procedure passing several values.

When I try to run the report passing a long string as an input parameter, the server shows the following error:

com.jaspersoft.jasperserver.api.JSException: Error filling report
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'canales'
at row 1 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3607)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541) 
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2002) 
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2163) 
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2624) 
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2127) 
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2293) 
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:92) 
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(JRJdbcQueryExecuter.java:239) 
... 15 more
Anyul Rivas
  • 655
  • 2
  • 12
  • 31
  • 1
    And what is the problem? U have message why you got error / warning. String that u are passing is longer than column can store and need to bu truncated to maximum capacity of column – cichy Nov 28 '12 at 21:05
  • 1
    Is "you" really so hard to type? – tadman Nov 28 '12 at 21:06
  • Sorry for that, can't fix it now because of 5 min edit limit – cichy Nov 28 '12 at 21:16

1 Answers1

3

To disable errors raised by data truncation first check your currect configuration:

SHOW VARIABLES LIKE 'sql_mode'

You probably have something like this:

STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
STRICT_ALL_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

So simply remove STRICT_TRANS_TABLES or STRICT_ALL_TABLES (depends on storage engine) by executing

SET sql_mode = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

Best solution would be to check length of the string before you execute query, and truncate it if longer than it's possible

cichy
  • 10,464
  • 4
  • 26
  • 36
  • the problem is with the jaspersoft report server. I can run my queries as long as I want in any mysql editor successfully. – Anyul Rivas Jan 03 '13 at 16:45