Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Data trunctaion exception in saveOrUpdate

 
Nidhi Singhal
Ranch Hand
Posts: 89
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am getting a java.sql.DataTruncation exception when ever I call saveOrUpdate method.

I have checked all the field values I am saving and they seemed to be pretty fine and within the set limits.

Can anyone suggest what might be causing it?

Thanks,
Nidhi
 
Scott Johnson
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The DataTruncation exception provides details about the exception including which column was truncated and the number of bytes in the original value. What does it report?

Here's the Javadoc:

http://java.sun.com/j2se/1.5.0/docs/api/java/sql/DataTruncation.html

Is your save causing a trigger to fire? The trigger could be inserting/updating something that is being truncated.
 
Nidhi Singhal
Ranch Hand
Posts: 89
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the Javadoc.

Here's the DataTrunctation exception details:

index: int=-1
parameter: boolean=false
read: boolean=false
dataSize:int=-1
transferSize:int=-1
SQLState: java.lang.String=22001
next:java.sql.SQLException=java.sql.SQLException:String or binary data would be truncated

I am not very clear about what does index -1 means.
I am using a Java PreparedStatement to insert some data in the table which has quite a lot of fields.

- Nidhi
 
Scott Johnson
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm... Interesting.

Obviously an index of -1 is invalid. That seems to indicate the problem isn't with the update itself, but something triggered by the update.

I would check to see if there are any triggers on the table and investigate any sqls that they may be running.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic