db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kristian Waagan <Kristian.Waa...@Sun.COM>
Subject Re: varchar length
Date Tue, 25 Nov 2008 11:23:23 GMT
tom_ wrote:
> When defining a datatype with varchar(128) and providing an input with more
> than 128 characters the value is not inserted in the database. There is an
> error message "error when trying to cut to 128 characters" (translated from
> german). 
>   

Hello Tom,

Only trailing white space will be truncated by Derby. I *think* this is 
according to the SQL standard, but I haven't checked this (anyone?).

Two options would be to either extract a substring from the value in 
Java (i.e. before you call PreparedStatement.setString), or rely on 
exception handling to detect and handle the problem.


regards,
-- 
Kristian

> I could encrease the maximum length but when there are a lot of values with
> shorter length and only very few with longer length than 128 this would
> decrease the speed of search operations ...  
>   


Mime
View raw message