Go Back   Forum Care Forums > Development Reference Area > MySQL Discussion

Reply
 
LinkBack Thread Tools Display Modes
MySQL Data Truncation error???
Old
  (#1)
Guest
Guest
 
Posts: n/a
Default MySQL Data Truncation error??? - 06-04-2007, 07:45 AM

Hello,

Hoping to get some help on something that just makes no sense to me...
Here's hoping someone can help!

I have table setup with a data type as such:
max_dollars double(4,2)

I have a piece of Java code that takes a form entry and submits it to
the database. The insert command looks like this:
db_insert = "insert into BIG_MONEY (max_dollars) values
("+request.getParameter("maxdollars"))";
stmt.executeUpdate(db_insert);

The problem is that when I type in: 140 in the textbox, MySQL throws an
error that looks like this:
SQLException Data truncation: Out of range value adjusted for column
'max_dollars' at row 1

What gives??? I did some looking on the groups and found something that
said to try adding the following to the URL:
?jdbcCompliantTruncation=false

That eliminated the error, but now it just rounds off any number
greater than 100 to 99.99... Any ideas??? This is driving me mad...

Let me know if I left anything else out that might help... Oh, I'm
using MySQL version 5.0.27 and MySQL Java connector 5.04

Thank in advance...
Nino Skilj

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: MySQL Data Truncation error???
Old
  (#2)
Jerry Stuckle
Guest
 
Posts: n/a
Default Re: MySQL Data Truncation error??? - 06-04-2007, 07:45 AM

EMAIL REMOVED wrote:
> Hello,
>
> Hoping to get some help on something that just makes no sense to me...
> Here's hoping someone can help!
>
> I have table setup with a data type as such:
> max_dollars double(4,2)
>
> I have a piece of Java code that takes a form entry and submits it to
> the database. The insert command looks like this:
> db_insert = "insert into BIG_MONEY (max_dollars) values
> ("+request.getParameter("maxdollars"))";
> stmt.executeUpdate(db_insert);
>
> The problem is that when I type in: 140 in the textbox, MySQL throws an
> error that looks like this:
> SQLException Data truncation: Out of range value adjusted for column
> 'max_dollars' at row 1
>
> What gives??? I did some looking on the groups and found something that
> said to try adding the following to the URL:
> ?jdbcCompliantTruncation=false
>
> That eliminated the error, but now it just rounds off any number
> greater than 100 to 99.99... Any ideas??? This is driving me mad...
>
> Let me know if I left anything else out that might help... Oh, I'm
> using MySQL version 5.0.27 and MySQL Java connector 5.04
>
> Thank in advance...
> Nino Skilj
>


Well, you defined the field to take a maximum of 99.99. What do you
expect MySQL to do?

If you want to put 140 in there, you need to leave room for three digits
to the left of the decimal point.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
EMAIL REMOVED
==================
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top