Subject | Data Truncation in Selects |
---|---|
Author | Carsten Schäfer |
Post date | 2012-01-20T09:36:05Z |
We are using PreparedStatement for Selects.
We are getting DataTruncation Exceptions when using Strings in a Select
that are longer than the defined varchar column.
For example
SELECT t_apos.ID_APOS From t_apos WHERE t_apos.f_best_nr = ?
where f_best_nr is a varchar(30) column.
When i use SELECT t_apos.ID_APOS from t_apos WHERE t_apos.f_best_nr =
'xxx';
(without the ?) i can write strings with any length without getting an
exception.
So it seems to be a problem with the driver and not with the database.
Is this an already known problem?
This is the exception:
java.sql.DataTruncation: Data truncation
at
org.firebirdsql.jdbc.field.FBWorkaroundStringField.setString(FBWorkaroundStringField.java:97)
at
org.firebirdsql.jdbc.AbstractPreparedStatement.setString(AbstractPreparedStatement.java:402)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.firebirdsql.pool.PooledPreparedStatementHandler.invoke(PooledPreparedStatementHandler.java:166)
at org.firebirdsql.pool.$Proxy1.setString(Unknown Source)
(Firebird 2.5.1 64bit, Jaybird 2.1.6 is used)
Best Regards,
Carsten
[Non-text portions of this message have been removed]
We are getting DataTruncation Exceptions when using Strings in a Select
that are longer than the defined varchar column.
For example
SELECT t_apos.ID_APOS From t_apos WHERE t_apos.f_best_nr = ?
where f_best_nr is a varchar(30) column.
When i use SELECT t_apos.ID_APOS from t_apos WHERE t_apos.f_best_nr =
'xxx';
(without the ?) i can write strings with any length without getting an
exception.
So it seems to be a problem with the driver and not with the database.
Is this an already known problem?
This is the exception:
java.sql.DataTruncation: Data truncation
at
org.firebirdsql.jdbc.field.FBWorkaroundStringField.setString(FBWorkaroundStringField.java:97)
at
org.firebirdsql.jdbc.AbstractPreparedStatement.setString(AbstractPreparedStatement.java:402)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.firebirdsql.pool.PooledPreparedStatementHandler.invoke(PooledPreparedStatementHandler.java:166)
at org.firebirdsql.pool.$Proxy1.setString(Unknown Source)
(Firebird 2.5.1 64bit, Jaybird 2.1.6 is used)
Best Regards,
Carsten
[Non-text portions of this message have been removed]