Connecting Tech Pros Worldwide Help | Site Map

MysqlDataTruncation and jdbcCompliantTruncation

newsgroups@raincode.net
Guest
 
Posts: n/a
#1: Feb 13 '06
Hi Gang,

Regarding the MysqlDataTruncation issue, I am having trouble
over-riding it with:
url=jdbc:mysql://localhost/mysql?jdbcCompliantTruncation=false

I am still getting the exception thrown in some cases:
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Out of range value
adjusted for column 'some_field' at row 1


However sometimes it is thrown and sometimes not. With building my
connection like:

String url=("jdbc:mysql://localhost/mydb");
Properties p = new Properties();
p.setProperty("user","myusername");
p.setProperty("password","mypassword");
Class.forName("com.mysql.jdbc.Driver").newInstance ();
Connection conn = DriverManager.getConnection(url,p);

My result is:

MySQL 4.1 on WindowsXP - exception is not thrown
MySQL 4.1 on Linux (SuSE9.2) - exception is not thrown
MySQL 5.0.18 on Linux (SuSE9.2) - exception is not thrown

--> MySQL 5.0.18 on WindowsXP - exception *IS THROWN*

At least, this is my experience. On the MySQL 5.0.18 on WindowsXP I
also tried this:

String url=("jdbc:mysql://localhost/mydb");
Properties p = new Properties();
p.setProperty("user","myusername");
p.setProperty("password","mypassword");
p.setProperty("jdbcCompliantTruncation","false"); //new line
Connection conn = DriverManager.getConnection(url,p);


I still get the exception thrown.
Also if I just try to change things like:

String url=("jdbc:mysql://localhost/mydb");
String user=("myusername");
String password=("mypassword");
Class.forName("com.mysql.jdbc.Driver").newInstance ();
Connection conn = DriverManager.getConnection(url, user, password);


I still get the exception on MySQL 5.0.18 on Windows, but nowhere else.
How can I get the Windows w/ MySQL 5.0.18 to ignore this
exception...that is, without going through my code to find instances
where I am passing data larger than the field size? That is the
long-term goal, but for now I am hoping to over-ride the exception. My
attempts at jdbcCompliantTruncation=false have failed.

Thanks,
Rob

references:
http://forums.mysql.com/read.php?39,...7969#msg-17969
http://www.thescripts.com/forum/thread141618.html
http://dev.mysql.com/doc/refman/5.0/...changelog.html
http://dev.mysql.com/doc/refman/5.0/...roperties.html

newsgroups@raincode.net
Guest
 
Posts: n/a
#2: Feb 15 '06

re: MysqlDataTruncation and jdbcCompliantTruncation


Hi folks,

Just wondering if anyone else has this exception being thrown after
moving to MySQL 5 on Windows XP. I do *not* get the same exception
throw when running MySQL 5 on Linux or Solaris, or MySQL 4.1 on any OS.

com.mysql.jdbc.MysqlDataTruncation: Data truncation: Out of range value
adjusted for column 'some_field' at row 1

Or if not using jdbc driver and instead at mysql>...

ERROR 1406 (22001): Data too long for column 'field1' at row 1

I know why the exception is thrown. Is there a way to ask MySQL (or
the JDBC driver) to ignore the error? My attempts have failed.

Thanks,
Rob

mark@thematthews.org
Guest
 
Posts: n/a
#3: Feb 15 '06

re: MysqlDataTruncation and jdbcCompliantTruncation


Sounds like your mysql installation is setup to use "strict-mode",
which will cause truncations to be sent to the client as _errors_. The
JDBC driver can't "ignore" the truncations in this case.

See
http://dev.mysql.com/doc/refman/5.0/...etworking.html

Closed Thread


Similar MySQL Database bytes