From: Kris Jurka <books@ejurka.com>
To: Віталій Тимчишин <tivv00@gmail.com>
Cc: PG-JDBC Mailing List <pgsql-jdbc@postgresql.org>
Subject: Re: Using java.lang.Character for "char" data type
Date: Fri, 21 May 2010 18:16:02 -0400 (EDT)
Message-ID: <alpine.BSO.2.00.1005211813180.22460@leary.csoft.net> (raw)
In-Reply-To: <AANLkTinKef9bhdEhYMMzxiRLKUXtGt_cUOnIPT5sibXI@mail.gmail.com>
References: <AANLkTinKef9bhdEhYMMzxiRLKUXtGt_cUOnIPT5sibXI@mail.gmail.com>
On Fri, 21 May 2010, ??????? ???????? wrote:
> I've tried to use Character to fill "char" column, e.g. like in the next
> test:
> -----
> con.createStatement().execute("create table tst(tcol \"char\")");
> PreparedStatement stmt = con.prepareStatement("insert into tst(tcol)
> values(?)");
> stmt.setObject(1, 'c');
> stmt..executeUpdate();
> -----
> and got
> Exception in thread "main" org.postgresql.util.PSQLException: Can't infer
> the SQL type to use for an instance of java.lang.Character. Use setObject()
> with an explicit Types value to specify the type to use. atorg.postgresql.jdbc2.AbstractJdbc2Statement.setObject(AbstractJdbc2Statemen
> t.java:1740)
>
> with 8.3-603.jdbc4 driver.
> May be it would be reasonable to treat Character like String of size 1?
>
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.
Kris Jurka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: books@ejurka.com, tivv00@gmail.com
Subject: Re: Using java.lang.Character for "char" data type
In-Reply-To: <alpine.BSO.2.00.1005211813180.22460@leary.csoft.net>
References: <AANLkTinKef9bhdEhYMMzxiRLKUXtGt_cUOnIPT5sibXI@mail.gmail.com> <alpine.BSO.2.00.1005211813180.22460@leary.csoft.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox