MysqlDataTruncation and jdbcCompliantTruncation
am 13.02.2006 19:09:31 von newsgroupsHi 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