import junit.framework.TestCase; import java.sql.*; import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; import java.math.BigInteger; /** * Created by IntelliJ IDEA. * User: Bjarte1 * Date: 19.okt.2004 * Time: 14:07:22 */ public class TestBug5729 extends TestCase { public void test01() throws SQLException, ClassNotFoundException { Connection conn = null; try { long id = 1095923280000L; Class.forName("com.mysql.jdbc.Driver"); conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1/test", "root", ""); Statement stmt = conn.createStatement(); stmt.execute("DROP TABLE if exists testBug5729"); stmt.execute("CREATE TABLE testBug5729 (tst_timestamp bigint unsigned)"); stmt.execute("INSERT INTO testBug5729 (tst_timestamp) values (" + id + ")"); PreparedStatement pStmt = conn.prepareStatement("select * from testBug5729"); ResultSet res = pStmt.executeQuery(); if (res.next()) { assertEquals(id, res.getLong("tst_timestamp")); } pStmt.close(); stmt.close(); } finally { closeConnection(conn); } } public void test02() { long id = 1095923280000L; BigInteger bint = ResultSetExt.convertLongToUlong(id); assertEquals(id, bint.longValue()); } private static void closeConnection(Connection conn) { try { if (conn != null) conn.close(); } catch (SQLException e) {} } private static class ResultSetExt extends com.mysql.jdbc.ResultSet { public ResultSetExt() { super(0, 0, null, null); } public static BigInteger convertLongToUlong(long num) { return com.mysql.jdbc.ResultSet.convertLongToUlong(num); } } }