Subject Re: org.firebirdsql.jdbc.field.TypeConvertionException: Error converting to long.
Author joerg_froeber
--- In Firebird-Java@yahoogroups.com, Roman Rokytskyy <roman@...>
wrote:
>
> > When debugging, the rsmd.getColumnType(i) of the num15_0 field
> > resolves to 12, which is the constant for java.sql.Types.VARCHAR.
So
> > the default case of the switch-statement is called and the
following
> > error occurs:
> > org.firebirdsql.jdbc.field.TypeConvertionException: Error
converting
> > to long.
> > at
> >
org.firebirdsql.jdbc.field.FBLongField.setString(FBLongField.java:131)
> > at
> >
org.firebirdsql.jdbc.AbstractPreparedStatement.setString(AbstractPreparedStatement.java:384)
> > at
> >
de.indv.db.DBConnection.executePreparedStatement(DBConnection.java:129)
> >
> > Is there a bug in firebird/jaybird or am I doing something wrong?
>
> I would say that you get the VARCHAR there. Two reasons:
>
> a) I checked the sources, and I am pretty sure that for
NUMERIC(15,0)
> Jaybird would return Types.NUMERIC
>
> b) Even if not, it would then convert the number into a String in
> rs.getString() method and the ps.setString(...) would parse the
number,
> convert it into Long and send back to the server. Since we have no
> decimal point, it will be 100% parsable. But you get an error there.
>
> Therefore, please check the contents of the field.
>
> If it does not work, please prepare a reproducable test case, I
will
> check it.
>
> Thanks!
> Roman
>

I built a test case and everything worked as expected.
After further examination I found a missing comma in my sql query,
which didn't lead to an error when the ResultSet was fetched, but
caused the above error, when trying to set a Varchar value in a long
field.

Sorry for the troubles I caused and thanks for your help.

Regards
Jörg