Solved

data truncation error / use jdbcCompliantTruncation?

Posted on 2006-10-20
8
752 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
ID: 17778516
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
ID: 17778585
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
ID: 17874863
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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

Author Comment

by:baldcode
ID: 18038577
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
ID: 18040801
have you tried executing the query?
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 19539058
PAQed with points refunded (300)

Computer101
EE Admin
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MySQL - Limit or Top Records 15 49
html input clean up 3 54
Instering to MySQL table 5 47
Need Wordpress help to link from outside to image item number. 6 36
I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

785 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