Solved

data truncation error / use jdbcCompliantTruncation?

Posted on 2006-10-20
8
801 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

 

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

Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

Question has a verified solution.

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

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…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

695 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