Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 43F0C635373 for ; Thu, 27 May 2010 16:29:23 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 27573-03-3 for ; Thu, 27 May 2010 19:29:15 +0000 (UTC) Received: from news.hub.org (news.hub.org [200.46.204.72]) by mail.postgresql.org (Postfix) with ESMTP id A852663469E for ; Thu, 27 May 2010 16:29:09 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.14.3/8.14.3) with ESMTP id o4RJSlKK031458 for ; Thu, 27 May 2010 16:29:06 -0300 (ADT) (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.14.3/8.14.3/Submit) id o4M1BdaI080154 for pgsql-jdbc@postgresql.org; Fri, 21 May 2010 22:11:39 -0300 (ADT) (envelope-from news) From: Lew X-Newsgroups: pgsql.interfaces.jdbc Subject: Re: Using java.lang.Character for "char" data type Date: Fri, 21 May 2010 21:11:52 -0400 Organization: albasani.net Lines: 30 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@albasani.net X-User-ID: SeI1KClPOw3g0FFlJ4DvV4yfebb+k2h/4nyaAPhPJB4= In-Reply-To: Cancel-Lock: sha1:Eh4UHThOqsPl6JcJzC6stkAcSBM= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100423 Thunderbird/3.0.4 X-NNTP-Posting-Host: +CHLSdiBbAVfeQJ2Opre/epYwA5SW/9//PwT1bsHRHQ= To: pgsql-jdbc@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.011 tagged_above=-10 required=5 tests=BAYES_40=-0.001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201005/80 X-Sequence-Number: 20564 Kris Jurka wrote: > It would be possible to support setObject for a Character, but be aware > that "char" is not a character long, it's a byte long, so it will fail > on multibyte characters. I'm a little confused. When you say "char" is a byte long, are you referring to the SQL type or the Java type? I'm used to seeing the Java type expressed in lower case and the SQL type in upper case, so please pardon my confusion. The Java 'char' type is 16 bits wide. Doesn't the width of the SQL "CHAR" depend on the encoding? Otherwise how does it handle, say, UTF-8 when you tell the DB to use that? To put it another way, suppose I enter a String that contains, say, 24 UTF-8 characters, some of which require multibyte encodings, and try to jam it into a "CHAR(24)" column or a "VARCHAR(24)" column. Will that cause trouble? The documentation for CHAR and VARCHAR at says "SQL defines two primary character types: character varying(n) and character(n), where n is a positive integer. Both of these types can store strings up to n characters (not bytes) in length." That seems to contradict what you said. -- Lew