users@glassfish.java.net

bug in CachedRowSetXImpl or MySQL?

From: <glassfish_at_javadesktop.org>
Date: Sun, 17 Feb 2008 11:01:24 PST

Hi,

I've adapted the Travel databases from Derby to MySQL and follow many Tutorials with success so far except the InsertUpdateDelete
http://www.netbeans.org/kb/60/web/inserts-updates-deletes.html
In this tutorial, I've encountered an error/bug (?)...

Here are the code snippets

sql syntax to get the id field. (TRIPID is INT(11) in mysql)
SELECT MAX(TRAVEL.TRIP.TRIPID)+1 AS MAXTRIPID FROM TRAVEL.TRIP

javacode to get value for the "save" action.
int newTripId = ((Integer) maxTrip.getValue("MAXTRIPID"));

where it generates this error:
Error :java.lang.Long cannot be cast to java.lang.Integer

So I did added few lines of code to see the field type and value before maxTrip.getValue
maxTrip.getType("MAXTRIPID").toString() ==> returns "long"
maxTrip.getValue("MAXTRIPID" ==> returns value of 593

But if I change the codes to as follow:
SELECT MAX(TRAVEL.TRIP.TRIPID) AS MAXTRIPID FROM TRAVEL.TRIP

and
int newTripId = ((Integer) maxTrip.getValue("MAXTRIPID")) + 1;

The "save" action works. So then I tried CAST in the sql statement
SELECT (cast(MAX(TRAVEL.TRIP.TRIPID)+1) AS UNSIGNED) AS MAXTRIPID FROM TRAVEL.TRIP

and received this error on "save" action:
Error :java.math.BigInteger cannot be cast to java.lang.Integer

So how does a small value (594) of BigInteger type + 1 gets converted to a Long type?

I'm using jdk1.5 update 14 with java_app_platform_sdk-5_04-windows-nojdk.exe and mysql 6.0.3-alpha-community-log on windows xp x86.

Thanks,
Tommy
[Message sent by forum member 'tommyhp2' (tommyhp2)]

http://forums.java.net/jive/thread.jspa?messageID=259409