MysqlDataTruncation and jdbcCompliantTruncation

MysqlDataTruncation and jdbcCompliantTruncation

am 13.02.2006 19:09:31 von newsgroups

Hi Gang,

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

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,15869,17969#msg-17969
http://www.thescripts.com/forum/thread141618.html
http://dev.mysql.com/doc/refman/5.0/en/cj-changelog.html
http://dev.mysql.com/doc/refman/5.0/en/cj-configuration-prop erties.html

Re: MysqlDataTruncation and jdbcCompliantTruncation

am 15.02.2006 16:47:04 von newsgroups

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

Re: MysqlDataTruncation and jdbcCompliantTruncation

am 15.02.2006 22:31:50 von mark

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/en/mysql-config-wizard-n etworking.html