Solved

data truncation error / use jdbcCompliantTruncation?

Posted on 2006-10-20
8
704 Views
Last Modified: 2008-01-09
I've got a web app in ColdFusion feeding a MySQL 5 database.  I'm getting inconsistent errors when doing inserts -- inconsistent in that it is not always throwing an error.  When it does throw an error, the error is

Data truncation: Data truncated for column 'COLUMN_NAME'

I've Googled around and suspect this might be a case where I need to set the JDBC driver with a parameter reading

jdbcCompliantTruncation=false

However, other searches come up with folks saying this does not help them.  My question is twofold.  First, if I'm running MySQL 5.0.19, should I be looking for a patch or upgrade?  

Second, can anyone point me to a workaround that would not necessitate a db patch/upgrade?  

Thanks!
Baldy
0
Comment
Question by:baldcode
8 Comments
 
LVL 6

Expert Comment

by:chigs20
Comment Utility
I recommend upgrading to the newest version 5.0.26 as it has a several major fixes for stored procs and security patches.  Next, can you provide some more insight to your error...
1. does the insert statement work if you execute by itself
2. can you post what your cfmx data source info (name, driver, connection string, etc.)
3. is there anything in the mysql error log
0
 

Author Comment

by:baldcode
Comment Utility
Oh, I neglected to mention the data type:  decimal 9, 2

The insert statement by itself is fine.  Usually, it works in the application.  

The datasource is specified by a variable...  not sure why the name would be important -- it's not a reserved word or anything.  The driver connection is pretty generic:

jdbc:mysql://127.0.0.1:3306/name_of_db

Would the truncation parameter need to go onto that?  If so, do I just add it with a question mark then the parameter?  

The mysql error log doesn't show anything.  Will look into the upgrade though!

- Baldy  
0
 
LVL 35

Expert Comment

by:Raynard7
Comment Utility
Hi,

Because there is nothing going through the mysql error log the problem is unlikley to be on the mysql side.

If you are doing this as a parameterised query this could be the problem as there has been some documented bugs surrounding data truncation and jdbc.

Potentially you could just get jdbc to execute a query string - and then this should not truncate your data as jdbc is not doing any transposition.  additoinally if you did it this way then you could check that you could run your insert statement through the mysql client and if you got errors that way - if you did not then it should work through jdbc.
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:baldcode
Comment Utility
I'm still interested and have upped the points.  Adding the jdbcomplianttruncation=false parameter to the jdbc string does not stick on CFadmin where the datasource is set up.  I found this very odd.

My workaround thus far has been to include a ColdFusion function on the data inserted to force it to conform to the size the field is set to (2 decimal places).  Not my favorite solution as there could appear other queries later that have the same issue and will need the same treatment.  I'd rather the shotgun approach on this one.  

Oh, well.  If no other comments or suggestions, you could just close this out.

Thanks!
Baldy
0
 
LVL 35

Expert Comment

by:Raynard7
Comment Utility
have you tried executing the query?
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
Comment Utility
PAQed with points refunded (300)

Computer101
EE Admin
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I use MySQL for many of my development projects in a Windows environment. To manage my databases (and perform queries) for years I used a tool called MySQL administrator.  This tool has since been replaced by MySQL Workbench. So I decided to m…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now