package testsuite.simple; import testsuite.BaseTestCase; import java.math.BigDecimal; public class TestBug22290 extends BaseTestCase { public TestBug22290 (String name) { super(name); } /* *Test for Bugs: #22290: Updating value in DECIMAL column with same datatype causes data truncation error, * * * @throws Exception */ public void testbug22290() throws Exception { createTable("testbug22290", "(`id` int(11) NOT NULL default '1',`cost` decimal(10,2) NOT NULL,PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8"); assertEquals(this.stmt.executeUpdate("INSERT INTO testbug22290 (`id`,`cost`) VALUES (1,'1.00')"),1); try { this.pstmt = this.conn.prepareStatement("update testbug22290 set cost = cost + ? where id = 1"); this.pstmt.setBigDecimal(1, new BigDecimal("1.11")); System.out.println("Query to be executed: "+this.pstmt.toString()); assertEquals(this.pstmt.executeUpdate(),1); } finally { closeMemberJDBCResources(); } } /** * @param args */ public static void main(String[] args) { junit.textui.TestRunner.run(TestBug22290.class); } }