Hello Kristian, this is a good idea, truncating by java before writing by SQL. Yes, varchar removes trailing blanks, though it would help if it would cut larger values instead of not writing them. If you have a look at the error message it shows that he tries to cut the value to the limit but has an exception. Thank you for helping Tom
Kristian Waagan-4 wrote: > > 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 ... >> > > > -- View this message in context: http://www.nabble.com/varchar-length-tp20669171p20680266.html Sent from the Apache Derby Users mailing list archive at Nabble.com.
