Bug #14710 jdbcCompliantTruncation not working
Submitted: 7 Nov 2005 16:13 Modified: 8 Nov 2005 11:10
Reporter: Daniel J. Melo Brasil Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:3.1.11 OS:Windows (Windows 2000 server)
Assigned to: Assigned Account CPU Architecture:Any

[7 Nov 2005 16:13] Daniel J. Melo Brasil
Description:
I´m configuring a connection with the property jdbcCompliantTruncation=false but the property does not have the expected result.

How to repeat:
import java.sql.Connection;
import java.sql.DataTruncation;
import java.sql.DriverManager;
import java.sql.Statement;

import junit.framework.TestCase;

public class DatabaseTest extends TestCase {

	public void setUp() throws Exception {

	}

	public void tearDown() throws Exception {

	}

	public void testJdbcDataTruncation() throws Exception {
		Class.forName("com.mysql.jdbc.Driver");
		String dburl = "jdbc:mysql://server/TEST";
		String dburlTrunc = "jdbc:mysql://server/TEST?jdbcCompliantTruncation=false";
		String dbuser = "TEST";
		String dbpass = "TEST";
		Connection connection = DriverManager.getConnection(dburl, dbuser,
				dbpass);
		Statement stm = connection.createStatement();
		stm.execute("DROP TABLE IF EXISTS `test`");
		stm.execute("CREATE TEMPORARY TABLE `test` ("
				+ "  `idTest` int(11) NOT NULL auto_increment,"
				+ "  `test_1` varchar(5) default NULL,"
				+ "  `test_2` varchar(5) default NULL,"
				+ "PRIMARY KEY  (`idTest`))");
		try {
			stm
					.execute("insert into test values (null,'12345','123456789')");
			fail();
		} catch (Exception e) {
		}
		stm.close();
		connection.close();
		connection = DriverManager.getConnection(dburlTrunc, dbuser, dbpass);
		stm = connection.createStatement();
		stm.execute("DROP TABLE IF EXISTS `test`");
		stm.execute("CREATE TEMPORARY TABLE `test` ("
				+ "  `idTest` int(11) NOT NULL auto_increment,"
				+ "  `test_1` varchar(5) default NULL,"
				+ "  `test_2` varchar(5) default NULL,"
				+ "PRIMARY KEY  (`idTest`))");
		try {
			stm
					.execute("insert into test values (null,'12345','123456789')");
		} catch (DataTruncation e) {
			fail("Error:" + e.getMessage());
		}

	}

}

Suggested fix:
No suggestions.
[7 Nov 2005 18:28] Daniel J. Melo Brasil
I executed this test using MySQL 5.0.15-nt and this error ocurred. I executed this test using MySQL 4.1.12a-nt and this error didn´t occur. I think that the problem is that instead of throwing a Warning, MySQL 5.0.15 throws an Error when the insert is executed.
[8 Nov 2005 11:10] Vasily Kishkin
Sorry...the bug report duplicates http://bugs.mysql.com/bug.php?id=14048