This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MysqlDataTruncation

 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ranchers,
I'm working in JSP and MySQL. the table details of the mysql table is this

When i try to insert the values thru the jsp page.. it is showing error..
the query running behind this is


The error i'm getting is this



What may be the error.. Please help me ranchers!!

Thanks in advance..

regards
Aravind Prasad
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Truncation means shortening. The data type for the field usd_amt is decimal(10,2) which means you can store a floating point number with a maximum of ten digits, of which two can be right of the decimal point. The value you are trying to insert is thei: 1.0305555555555554, so MySQL would have to truncate the number to 1.03 in order to insert it, and that is why you see this exception.
 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankyou Paul Sturrock,
When i tried to insert the query using JSP front end is was showing the error, but when i tried it out using the mysql prompt it was working perfectly and was inserting it like x.yy format. So the problem is with the JSP coding!!
Also when i searched in Google using the error, i got the results like, to change the jdbc connecter.?
is that possible..


Can you please fix for me this problem.

regards
Aravind Prasad
 
Rama Krishna Ghanta
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Aravind,

I dont understand how a connector helps you fix this exception. How does a connector help in changing the basic properties of a DATATYPE? The only ways you can fix this is, either change the data type to decimal(10,2) to decimal(somenumber,somebignumber) or Round the decimal value to two digits if your requirement permits.

Thanks,
Rama Krishna Ghanta
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic