You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you create a statement with a parameter, and the parameter value length exceeds the field length occurs. Example:
Create table test(value varchar(6))
PreparedStatement ps = connection.prepareStatement("select * from test where value like ?");
ps.setString(1, "1234567"); >>>>> java.sql.DataTruncation: Data truncation
ps.executeQuery()
Now, if I hardcode the parameter in SELECT there is no exceptions.
PreparedStatement ps = connection.prepareStatement("select * from test where value like '1234567'");
ps.executeQuery()
The text was updated successfully, but these errors were encountered:
This is unfortunately a limitation of Firebird that parameters are limited to the length of the column they are compared against. It works with literals in a query because there the literal defines the length. The only viable workaround is to explicitly cast the parameter to a wider value (eg cast(? as varchar(100))).
In theory Jaybird could redeclare the variable to be wider, but that would only end up shifting the origin of the exception from Jaybird to Firebird, because Firebird would then generate a string truncation error anyway.
Submitted by: Beto Neto (betoneto.tbo)
Is related to CORE3559
When you create a statement with a parameter, and the parameter value length exceeds the field length occurs. Example:
Create table test(value varchar(6))
PreparedStatement ps = connection.prepareStatement("select * from test where value like ?");
ps.setString(1, "1234567"); >>>>> java.sql.DataTruncation: Data truncation
ps.executeQuery()
Now, if I hardcode the parameter in SELECT there is no exceptions.
PreparedStatement ps = connection.prepareStatement("select * from test where value like '1234567'");
ps.executeQuery()
The text was updated successfully, but these errors were encountered: