package testsuite.simple; import java.sql.ResultSetMetaData; import java.sql.Types; import testsuite.BaseTestCase; public class TestBug24426 extends BaseTestCase { public TestBug24426(String name) { // TODO Auto-generated constructor stub super(name); } /** * @param args */ /** * Tests BUG#24426, incorrect JDBC type for DECIMAL columns. * * @throws Exception * if the test fails. */ public void testBug24426() throws Exception { try { String[] typesToTest = new String[] { "DECIMAL", "DOUBLE", "DOUBLE"}; short[] jdbcMapping = new short[] { Types.DECIMAL, Types.DOUBLE, Types.DOUBLE }; createTable("testbug24426", "(a int, b double)"); assertEquals(this.stmt.executeUpdate("insert into test values(1, 2)"),1); this.rs = this.stmt.executeQuery("SELECT a / a AS IntOverInt, b / a AS DoubleOverInt, b / b AS DoubleOverDouble FROM testbug24426"); ResultSetMetaData rsmd = this.rs.getMetaData(); for (int i = 0; i < typesToTest.length; i++) { assertTrue(jdbcMapping[i] == rsmd.getColumnType(i + 1)); String desiredTypeName = typesToTest[i];// + " unsigned"; assertTrue(rsmd.getColumnTypeName((i + 1)) + " != " + desiredTypeName, desiredTypeName .equalsIgnoreCase(rsmd.getColumnTypeName(i + 1))); } //TO BE REMOVED, JUST REPORTERS OWN CODE for (int c = 1; c <= rs.getMetaData().getColumnCount(); c++) { System.out.println( rs.getMetaData().getColumnName(c) + " => " + rs.getMetaData().getColumnType(c)); } } finally { closeMemberJDBCResources(); } } public static void main(String[] args) { // TODO Auto-generated method stub junit.textui.TestRunner.run(TestBug24426.class); } }