--- ResultSetRegressionTest.java~ 2005-12-12 16:08:07.000000000 +0000 +++ ResultSetRegressionTest.java 2005-12-12 16:08:07.000000000 +0000 @@ -2847,4 +2847,42 @@ } } } + + /** + * Tests fix for BUG#15677, wrong values returned from + * getShort() if SQL values are tinyint unsigned. + * + * @throws Exception if the test fails. + */ + public void testBug15677() throws Exception { + try { + createTable("testBug15677", "(id BIGINT, field1 TINYINT UNSIGNED)"); + this.stmt.executeUpdate("INSERT INTO testBug15677 VALUES (1, 0), (2, 127), (3, 128), (4, 255)"); + this.rs = this.conn.prepareStatement("SELECT field1 FROM testBug15677 ORDER BY id ASC").executeQuery(); + this.rs.next(); + assertEquals("0", this.rs.getString(1)); + assertEquals("0", this.rs.getObject(1).toString()); + assertEquals("0", String.valueOf(this.rs.getShort(1))); + + this.rs.next(); + assertEquals("127", this.rs.getString(1)); + assertEquals("127", this.rs.getObject(1).toString()); + assertEquals("127", String.valueOf(this.rs.getShort(1))); + + this.rs.next(); + assertEquals("128", this.rs.getString(1)); + assertEquals("128", this.rs.getObject(1).toString()); + assertEquals("128", String.valueOf(this.rs.getShort(1))); + + this.rs.next(); + assertEquals("255", this.rs.getString(1)); + assertEquals("255", this.rs.getObject(1).toString()); + assertEquals("255", String.valueOf(this.rs.getShort(1))); + } finally { + if (this.rs != null) { + this.rs.close(); + this.rs = null; + } + } + } }