Subject PreparedStatement chokes, executing similiar sql String prevails
Author nagypapi
I'm using jaybird 2.0.1 and fb152 ss
Database is default the dreaded and rigid UNICODE_FSS, I connect using
lc_ctype set to UNICODE_FSS. (the parameter values in this post may
differ from the originals because of the text encoding misery).

I have a query I want to execute, so first I created a
PreparedStatment. But whenever it returns with a non empty resultset
rs.next() throws an exception:

"org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544321.
arithmetic exception, numeric overflow, or string truncation
Cannot transliterate character between character sets
at
org.firebirdsql.jdbc.FBStatementFetcher.fetch(FBStatementFetcher.java:206)
at
org.firebirdsql.jdbc.FBStatementFetcher.next(FBStatementFetcher.java:119)
at org.firebirdsql.jdbc.FBResultSet.next(FBResultSet.java:250)
...
...
at org.firebirdsql.gds.GDSException: arithmetic exception, numeric
overflow, or string truncation
Cannot transliterate character between character sets
at
org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.readStatusVector(AbstractJavaGDSImpl.java:2104)
at
org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.receiveResponse(AbstractJavaGDSImpl.java:2054)
at
org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.iscDsqlFetch(AbstractJavaGDSImpl.java:1322)
at org.firebirdsql.gds.impl.GDSHelper.fetch(GDSHelper.java:260)
at
org.firebirdsql.jdbc.FBStatementFetcher.fetch(FBStatementFetcher.java:201)
at
org.firebirdsql.jdbc.FBStatementFetcher.next(FBStatementFetcher.java:119)
at org.firebirdsql.jdbc.FBResultSet.next(FBResultSet.java:250)
...
"

This was fishy, so I tried the same with executing dynamic sql, and it
succeeded with NO exceptions.

The table involved:

CREATE TABLE MAX_CONSTRAINT (
DEST SMALLINT,
MAXCONSTRAINT INTEGER NOT NULL,
NAME VARCHAR(50),
DATEOFMAX DATE,
PART_OF_DAY SMALLINT DEFAULT 0
);
ALTER TABLE MAX_CONSTRAINT ADD CONSTRAINT UNQ_MAX_CONSTRAINT UNIQUE
(DATEOFMAX, PART_OF_DAY);
CREATE INDEX MAX_CONSTRAINT_IDX_DATE ON MAX_CONSTRAINT (DATEOFMAX);
CREATE INDEX MAX_CONSTRAINT_IDX_NAME ON MAX_CONSTRAINT (NAME);

+privileges

the data:
INSERT INTO MAX_CONSTRAINT (DEST, MAXCONSTRAINT, NAME, DATEOFMAX,
PART_OF_DAY) VALUES (2, 5, 'műtő1', '2005-12-28', 0);
INSERT INTO MAX_CONSTRAINT (DEST, MAXCONSTRAINT, NAME, DATEOFMAX,
PART_OF_DAY) VALUES (2, 6, 'Műtő1', '2005-12-27', 1);
INSERT INTO MAX_CONSTRAINT (DEST, MAXCONSTRAINT, NAME, DATEOFMAX,
PART_OF_DAY) VALUES (2, 7, 'Műtő1', '2005-12-20', 0);


the non-working PreparedStatement involved:

getMaxConstraintsBetween=conn.prepareStatement(
"select maxconstraint,dateofmax,part_of_day,dest,name
from max_constraint
where name=? and dateofmax>=? and dateofmax<=? and dest=?
order by dateofmax,part_of_day");

the value of the parameters I set (they were variables):
setString(1,"Mûtõ1");
setString(2,"2005-12-26");
setString(3,"2006-01-01");
setInt(4,2);

The sql query that worked:
"select maxconstraint,dateofmax,part_of_day,dest,name from max_constraint
where name='Mûtõ1' and dateofmax>='2005-12-26' and
dateofmax<='2006-01-01' and dest=2
order by dateofmax,part_of_day"

Do you have any ideas on what might the cause of the Exceptions be?

John