473,324 Members | 2,370 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

MysqlDataTruncation and jdbcCompliantTruncation

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

Feb 13 '06 #1
2 7281
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

Feb 15 '06 #2
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

Feb 15 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Roy Epperson | last post by:
I just upgraded to MySQL to 4.1.9 and JDBC mysql-connector-java-3.1.6-bin.jar and now getting the following Exception: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data truncated for...
12
by: Juan Carlos Espinoza | last post by:
i have a problem com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data truncated for column 'FGiroNPagDol' at row 1 at...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.