Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 19456 invoked from network); 9 Nov 2006 20:55:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Nov 2006 20:55:05 -0000 Received: (qmail 40601 invoked by uid 500); 9 Nov 2006 20:55:13 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 39618 invoked by uid 500); 9 Nov 2006 20:55:11 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 39607 invoked by uid 99); 9 Nov 2006 20:55:11 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Nov 2006 12:55:11 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: local policy) Received: from [216.148.222.49] (HELO outbound2-red-R.bigfish.com) (216.148.222.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Nov 2006 12:54:56 -0800 Received: from outbound2-red.bigfish.com (localhost.localdomain [127.0.0.1]) by outbound2-red-R.bigfish.com (Postfix) with ESMTP id 01CEE177CC84 for ; Thu, 9 Nov 2006 20:54:36 +0000 (UTC) Received: from mail45-red-R.bigfish.com (unknown [172.18.12.3]) by outbound2-red.bigfish.com (Postfix) with ESMTP id EE7ED177AC03 for ; Thu, 9 Nov 2006 20:54:35 +0000 (UTC) Received: from mail45-red.bigfish.com (localhost.localdomain [127.0.0.1]) by mail45-red-R.bigfish.com (Postfix) with ESMTP id CD18C6825A6 for ; Thu, 9 Nov 2006 20:54:35 +0000 (UTC) X-BigFish: VP Received: by mail45-red (MessageSwitch) id 1163105675800641_8357; Thu, 9 Nov 2006 20:54:35 +0000 (UCT) Received: from localhost.localdomain (unknown [12.106.254.103]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (No client certificate requested) by mail45-red.bigfish.com (Postfix) with ESMTP id A45F7667F46 for ; Thu, 9 Nov 2006 20:54:35 +0000 (UTC) Received: from tu_asynch_1.tuc.com (tu_asynch_1.tuc.com [10.1.1.201]) by localhost.localdomain (8.12.10/8.12.10) with ESMTP id kA9KsXEw014132 for ; Thu, 9 Nov 2006 14:54:33 -0600 Received: from DOMNTU-MTA by tu_asynch_1.tuc.com with Novell_GroupWise; Thu, 09 Nov 2006 14:54:33 -0600 Message-Id: X-Mailer: Novell GroupWise Internet Agent 6.5.5 Date: Thu, 09 Nov 2006 14:54:22 -0600 From: "Qin Ding" To: , "Jakarta Commons Users List" Subject: Re: BeanUtils Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Checked: Checked by ClamAV on apache.org >>> flamefew@gmail.com 11/9/2006 11:03 AM >>> On 11/9/06, Qin Ding wrote: > in database, 'rqst_sts_cde' is defined as smallint. I don't know what > these 'Short' or 'Integer' come from. I guess from build-in converter. > What is 'smallint' supposed to convert to? And how to override the > build-in converter. Please help. Digging into the source, it looks like the Short is coming from the DB2 JDBC driver when BeanUtils asks it what type the DB2 smallint column should be represented as as a Java object. Line 169 ot JDBCDynaClass (in trunk): className = metadata.getColumnClassName(i); When BeanUtils then gets the data, it assumes that the object it gets via ResultSet.getObject (line 232 of RowSetDynaClass) is of the type that the database is advising it to use. I'm not sure if the JDBC spec intends for this to be done, but I suspect so. So I think this is a bug in the DB2 JDBC driver - it's not returning the type of Object it advises a client to create. Alfredo has the correct and easiest technical work-around - find a type that works with the JDBC driver at the database level - 'int' seems like a good choice. That might be hard to do if you're not in control of the schema though. Another work-around would be to extend RowSetDynaClass and override the copy(ResultSet) method to have a hack to get around this (by forcing the Integer into a Short when the underlying type is a Short), or more painfully, overriding createDynaBean() to return a dynabean that doesn't use Shorts but uses Integers instead. That involves overriding other methods though. Hen --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org