package testsuite.simple; import testsuite.BaseTestCase; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; public class TestBug22425 extends BaseTestCase { public TestBug22425 (String name) { super(name); } /* *Test for Bugs: #22425: Updating value in VARCHAR column causes data truncation error, * * * @throws Exception */ public void testbug22425() throws Exception { createTable("testbug22425", "(`username` varchar(20) NOT NULL default '') ENGINE=MyISAM DEFAULT CHARSET=utf8"); assertEquals(this.stmt.executeUpdate("insert into testbug22425 values ('foo'), ('bar'), ('baz'), ('chris');"),4); try { this.pstmt = this.conn.prepareStatement("INSERT INTO testbug22425 VALUES (?)"); this.pstmt.setString(1, "tonci"); System.out.println("Query to be executed: "+this.pstmt.toString()); assertEquals(this.pstmt.executeUpdate(),1); this.pstmt = this.conn.prepareStatement("INSERT INTO testbug22425 VALUES (?)"); this.pstmt.setString(1, "tonci 10.192.192.99"); System.out.println("Query to be executed: "+this.pstmt.toString()); assertEquals(this.pstmt.executeUpdate(),1); this.pstmt = this.conn.prepareStatement("SELECT * from testbug22425 WHERE username LIKE ?"); this.pstmt.setString(1, "tonci%"); System.out.println("Query to be executed: "+this.pstmt.toString()); this.rs = this.pstmt.executeQuery(); System.out.println("Dumping data..."); dump(this.rs); } finally { closeMemberJDBCResources(); } } private static void dump(ResultSet rs) throws SQLException { ResultSetMetaData rsmd = rs.getMetaData(); for(int i=0; i