Re: Accessing CHAR columns in java
Posted in 1998
On Tue, 7 Jul 1998 13:02:43 -0500, "Candy McCall" <candym@olcinc.com> wrote: >As I understand it, when a CHAR(n) field is retrieved from the >database in Java (using JDBC), the driver will convert the >field to a Java String object of length n, padding spaces at >the end if necessary. It shouldn't pad spaces to the end. > And, when a String object is sent to >a CHAR(n) field, the driver and/or database will add any >necessary padding spaces to the end of the string to bring it up to >length n. The database engine should do this. > When coding in I-4gl, it seemed that any >character variable written to the database had its trailing blanks >clipped, or at least the INPUT statement of character variables >did that. It doesn't. In 4GL char variables are always of the length defined in 4GL (possibly via like table.column) and padded with spaces. If you wanted them clipped for printing or concatenation you had to used the clipped keyword. > I guess my question is, suppose you have a CHAR(4) >column for say "state" and you store the values of "TN", "GA", >and "FL" in that column. Each of those values are two-characters >each. Does Informix store the values as "TN ", "GA ", and >"FL ", with two blank spaces padded at the end for each value? They are stored with the spaces added. >I'm trying to determine a strategy for handling these CHAR >columns in java. I think I definitely want to trim the >white space at the end whenever I retrieve a CHAR column >from the database. Does anyone have any thoughts or >guidance? If your JDBC driver doesn't automatically trim trailing spaces you can do it yourself in Java. PS: Please turn off your mime/html posting option and post only plain text to this newsgroup if possible. Nils Myklebust NM Data AS Norway E-mail: Nils.Myklebust@nmdata.com FAQ at: http://www.iiug.org/techinfo/faq/faq_top.html (Now with ODBC info under "Third party products".)