Subject Re: OT: why is there no getInteger method in jdbc
Author DATACOM - Diego
Hi,

> 1b. Re: OT: why is there no getInteger method in jdbc
> Posted by: "Roman Rokytskyy" rrokytskyy@... rrokytskyy
> Date: Fri Nov 24, 2006 7:13 am ((PST))
>
>
>>there must be a good reason why this is missing from jdbc ?
>
>
> I guess Sun just did not want to polute the code with such methods. Even
> more, starting Java 5.0 the issue is gone due to autoboxing.

Roman, I dont think autoboxing will do the trick here. If the int is
NULL in the database, getInt() will return a zero, and autoboxing would
result in a Integer.valueOf(0) and not the desired null. Anyway, I think
autoboxing is evil and should be avoided in most situations.

>>is it a good idea to do this, or is there a better way ?
>
>
> If you're sure that the column is declared as INTEGER, you can use
> getObject(int) method. Otherwise you have to construct it yourself.

getObject(int) is a good option. However, an even better idea would be
to use some framework to abstract JDBC code, like Apache DBUtils,
Hibernate or JPA.

Regards,

--
DIEGO Moreira da Rosa

DATACOM
Av Fran├ža, 735 - Porto Alegre, RS - 90230-220
DDR: +55 51 3358 0141
Fax: +55 51 3358 0101
site: www.datacom.ind.br
e-mail: diego@...