Subject | Re: [Firebird-Java] Re: TypeConvertionException |
---|---|
Author | Carsten Schäfer |
Post date | 2002-04-03T07:52:46Z |
Here is some exmaple when i get an exception:
try {
float b1 = (float)rs.getDouble("f_breite");
double b2 = rs.getDouble("f_breite");
System.err.println("b1 == b2 ? "+(b1 == b2));
float f = rs.getFloat("f_breite");
} catch(SQLException ex) {
System.err.println("Got SQLException, double value is " +
Double.toString(rs.getDouble("f_breite")));
}
b1 == b2 ? true
Got SQLException, double value is -1.0
b1 == b2 ? true
Got SQLException, double value is -1.0
b1 == b2 ? true
Got SQLException, double value is -1.0
b1 == b2 ? true
Got SQLException, double value is -1.0
try {
float b1 = (float)rs.getDouble("f_breite");
double b2 = rs.getDouble("f_breite");
System.err.println("b1 == b2 ? "+(b1 == b2));
float f = rs.getFloat("f_breite");
} catch(SQLException ex) {
System.err.println("Got SQLException, double value is " +
Double.toString(rs.getDouble("f_breite")));
}
b1 == b2 ? true
Got SQLException, double value is -1.0
b1 == b2 ? true
Got SQLException, double value is -1.0
b1 == b2 ? true
Got SQLException, double value is -1.0
b1 == b2 ? true
Got SQLException, double value is -1.0
----- Original Message -----
From: ""rrokytskyy"" <rrokytskyy@...>
Newsgroups: egroups.ib-java
Sent: Wednesday, April 03, 2002 5:31 AM
Subject: [Firebird-Java] Re: TypeConvertionException
>
> > I 've changed all my getFloat to (float)rs.getDouble and now it
> > works. So i think all my values are 'castable'.
>
> double d = rs.getDouble();
> float f = (fload)d;
>
> will not throw any exception. BUT! if d > Float.MAX_VALUE, then the
> following assertion will fail: d == (double)f. This means, that the
> value you have in double is DIFFERENT from the value you have in
> float.
>
> I would be very grateful if you could add in your application the
> following code and report the results:
>
> try {
> float f = rs.getFloat();
> } catch(SQLException ex) {
> System.out.println("Got SQLException, double value is " +
> Double.toString(rs.getDouble());
> }
>