db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Jefferson <a...@jpox.org>
Subject Re: Binding a char to PreparedStatement
Date Wed, 20 Jul 2005 07:25:02 GMT
Hi Michael,

> we have a lot of derby errors "ERROR 22001: A truncation error was
> encountered trying to shrink CHAR 'XXX' to length 1."

I've never seen one of these in our testcases, so we've got some difference in 
how the TCK is specifying things and how we've done it.

> I analysed the problem writing a little Java program that uses JDBC
> directly. The program inserts a row into a table having a single CHAR(1)
> column. The program uses a prepared statement and binds a Java character
>   to it using different methods:
> 1) PreparedStatement.setShort
> 2) PreparedStatement.setInt
> 3) PreparedStatement.setObject
> 4) PreparedStatement.setString

What type is the Java type and what type is the DB column ? (and is there a 
jdbc-type specified in the MetaData?). Give an example of a Java field, its 
MetaData entry, and the RDBMS column type and we should be able to isolate 
this [OK, I could run the TCK and try to find one, but since you have these 
fresh in your memory its easier to ask you :-)]

JPOX could use many different JDBC methods depending on what Java type and 
what RDBMS type so it depends on your situation. For example :-
Java=char/Character, RDBMS="INTEGER", uses JDBC setInt()
Java=char/Character, RDBMS="CHAR", uses JDBC setString()


View raw message