4 messages in com.mysql.lists.javaRe: emptyStringsConvertToZero and jdb...
FromSent OnAttachments
Ronald Boettcher13 Jul 2005 01:15 
Ronald Boettcher13 Jul 2005 01:27 
Mark Matthews13 Jul 2005 05:17 
Ronald Boettcher13 Jul 2005 08:00 
Subject:Re: emptyStringsConvertToZero and jdbcCompliantTruncation
From:Mark Matthews (ma@mysql.com)
Date:07/13/2005 05:17:29 AM
List:com.mysql.lists.java

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1

Ronald Boettcher wrote:

There is a problem when using the MySQL-4 properties _emptyStringsConvertToZero_ and _jdbcCompliantTruncation_ together, i.e. are both set to "true".

We have migrated from MySQL 3 to 4 last time and now I am running into several problems, of course ;-). The most of them could be solved, but there is an inconsistency IMHO, which I have to report:

I want to use the new feature of throwing a java.sql.DataTruncation exception to create appropriate log information. This exception will also be thrown when empty strings are used for not-char columns (e.g. decimals like 'int(11)' etc.) in Insert or Update commands. Okay, I said to me, there is another database driver property called _emptyStringsConvertToZero_ which I can switch on. But it doesn't work as expected: the java.sql.DataTruncation exceptions are throwing further on :-( while the empty strings are treated correctly as '0'. Only when I set _jdbcCompliantTruncation_ to "false" it works, but behaves much like MySql 3 which I do not want to have ;-).

It seems to me that this could be a simple ordering problem. I.e. if the property _emptyStringsConvertToZero_ is set to "true" it has to be processed *before* checking truncation (if _jdbcCompliantTruncation_ is also "true").

Ronald,

JDBC compliant truncation would not allow empty strings to be converted to zero (it's part of the spec), so I suppose to be correct we'd need to add another option, or alternatively be very careful how we word the description of "emptyStringsConvertToZero". The two behaviors are actually orthoganal in my mind.

-Mark

iD8DBQFC1QZvtvXNTca6JD8RAo5GAKC5aojhd5VXMeWJjaNvGv/olRkBwACfTGrC VErcNkm3Afq0EZJPwqGfShc= =z/5c -----END PGP SIGNATURE-----