Kevin,

What you are overlooking is that 4294967298 is outside the range of Java's
int--it's 0x100000002.  So, when it's converted to int, the high order bit
gets discarded, and you are left with a result of 2.  JDBC behaves as would
be expected.

public class TestLong {
    final public static void main(String[] args) {
        long theLong = 4294967298L;
        System.out.println("(int) 4294967298L = " + (int) theLong);
    }
}

C:\javabox>java TestLong
(int) 4294967298L = 2

HTH
Bill

====== original message follows ======

Date: Mon, 11 Jul 2005 13:54:12 -0400
From: Kevin McAllister <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]

Hello,

[...]
The problem comes in with fields of type "int(11) unsigned" these are
obviously interpreted as Longs on call to resultSet.getObject() which is
fine, the problem I am having is that calls to getLong() and getInt()
return different looking values.

[...]
Code I have runs this query
"SELECT title, probabilityID FROM salesprobability"

And then iterates the result set, I put the following debugging code in
there:

while (rs.next()) {
  String title = rs.getString(1);
  long id = rs.getLong(2);
  int idInt = rs.getInt(2);
  System.out.println(title+", long Id: "+id+" intId: "+idInt);
}

And get results like:
10%, long Id: 4294967297 intId: 1
20%, long Id: 4294967298 intId: 2
30%, long Id: 4294967299 intId: 3

I assume I am overlooking something very obvious, But I would expect
that both the long and int interpretations of the value would be the
same, especially for numbers of that magnitude.

Thank you for any help anyone can offer.

Thanks,
Kevin


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to