Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQLException: Data truncated

 
joseph okon
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
I am trying to insert double data type into my database but it is giving me an exception which goes like this

this my java code

this is my database disription

can any member of the ranch tell me what is happening cause am loss , i can think of anything again
thanks in advance
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code doesn't actually use any of the parameters you're passing to it - it's passing along string literals. Instead of

... values('bankType',chequeNum, ...

you need something like

... values('"+bankType+"', "+chequeNum+", ...

It would be much better use PreparedStatement for this - that way you avoid the string concatenation, and also don't need to worry about quotes around string arguments.
 
joseph okon
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Dittmer
sorry i don't really understand what you mean.
please can you expanciate it for me maybe with an illustration code
thanks
joe

 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In that case it's probably best to start by working through the JDBC tutorial (http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/jdbc/index.html), and at first to get much simpler tables to work.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic