Subject | Re: org.firebirdsql.jdbc.field.TypeConvertionException: Error converting to long. |
---|---|
Author | joerg_froeber |
Post date | 2008-07-24T10:34:54Z |
--- In Firebird-Java@yahoogroups.com, Roman Rokytskyy <roman@...>
wrote:
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
wrote:
>So
> > When debugging, the rsmd.getColumnType(i) of the num15_0 field
> > resolves to 12, which is the constant for java.sql.Types.VARCHAR.
> > the default case of the switch-statement is called and thefollowing
> > error occurs:converting
> > org.firebirdsql.jdbc.field.TypeConvertionException: Error
> > to long.org.firebirdsql.jdbc.field.FBLongField.setString(FBLongField.java:131)
> > at
> >
> > atorg.firebirdsql.jdbc.AbstractPreparedStatement.setString(AbstractPreparedStatement.java:384)
> >
> > atde.indv.db.DBConnection.executePreparedStatement(DBConnection.java:129)
> >
> >NUMERIC(15,0)
> > 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
> Jaybird would return Types.NUMERICnumber,
>
> b) Even if not, it would then convert the number into a String in
> rs.getString() method and the ps.setString(...) would parse the
> convert it into Long and send back to the server. Since we have nowill
> 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
> check it.I built a test case and everything worked as expected.
>
> Thanks!
> Roman
>
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