Subject Re: PreparedStatements
Author Nick Sydenham
--- In Firebird-Java@yahoogroups.com, "Roman Rokytskyy"
<rrokytskyy@a...> wrote:
> > I'm getting the following error when trying to set an SQL Date in a
> > PreparedStatement:
> >
> > org.firebirdsql.jdbc.field.TypeConvertionException: Error converting
> > to date.
> > at org.firebirdsql.jdbc.field.FBField.setDate(FBField.java:744)
> > at
> >
>
org.firebirdsql.jdbc.AbstractPreparedStatement.setDate(AbstractPreparedStatement.java:191)
> > at
> >
>
com.atoc.datamig.AuditRecordProcessor.saveRecord(AuditRecordProcessor.java:271)
> >
> > which implies that something is not overriding the setDate method
> > somewhere.
>
> Exactly. Can you provide a test case or describe in details datatypes
> that you have in your query. Note, according to JDBC specs you can
> convert java.sql.Date to java.sql.Timestamp and String. No other
> conversions are possible.
>
> Roman

ps.setDate(4, parseDate(val));

where parseDate returns a java.sql.Date with the hours, minutes,
seconds and milliseconds set to 0.

I am assuming that with a PS of 'insert into table (f1, f2, f4, f3)
values (?, ?, ?, ?)' that the types are read in the order specified by
the SQL and not the order in which they are specified on the table.

So fields 1, 2 and 4 are varchars, field 3 is a date on the table
defintion. So PS.setDate(4, date) is still correct in theory.