> > Hi all
> > I am sure this has been asked before, but i can't seem to find the answer.
[quoted text clipped - 27 lines]
>
> return (Double) o;
How about going further and replacing the entire body of the method:
private Double getResultSetDouble(java.sql.ResultSet rs, String columnName)
throws java.sql.SQLException{
return (Double) rs.getObject(columnName);
}

Signature
Lee Fesperman, FirstSQL, Inc. (http://www.firstsql.com)
==============================================================
* The Ultimate DBMS is here!
* FirstSQL/J Object/Relational DBMS (http://www.firstsql.com)
Murray - 24 Jul 2004 07:19 GMT
> > > Hi all
> > > I am sure this has been asked before, but i can't seem to find the answer.
[quoted text clipped - 34 lines]
> return (Double) rs.getObject(columnName);
> }
I usually prefer:
private Double getResultSetDouble(java.sql.ResultSet rs, String columnName)
throws java.sql.SQLException{
double d = rs.getDouble(columnName);
if (rs.wasNull() {
return null;
else {
return new Double(d);
}
}
At least that way, if you get your datatypes mixed up you'll get an
SQLException telling you so, instead of a ClassCastException which can
sometimes be difficult to track down. Just a preference, the end result will
be the same ...
hilz - 24 Jul 2004 08:55 GMT
> I usually prefer:
>
> private Double getResultSetDouble(java.sql.ResultSet rs, String
columnName)
> throws java.sql.SQLException{
> double d = rs.getDouble(columnName);
[quoted text clipped - 4 lines]
> }
> }
Thanks Murray,
I liked this method.
thanks.
Luke Webber - 24 Jul 2004 23:49 GMT
> How about going further and replacing the entire body of the method:
>
> private Double getResultSetDouble(java.sql.ResultSet rs, String columnName)
> throws java.sql.SQLException{
> return (Double) rs.getObject(columnName);
> }
D'oh! Wood, trees etc. And the next step is naturally to dispense with
this method entirely. <g>
Luke