Re: error with unicode thing??

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: chinni <naveen(dot)bysani(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: error with unicode thing??
Date: 2004-08-30 11:40:47
Message-ID: 4133123F.9040107@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

chinni wrote:
> Hi all,
>
> I have created a table
> create table temp1(a varchar(200));
>
> and then I tried running the following code.
>
> String msg1 = "\u0000abcd";
> PreparedStatement preparedStmt =pgConnection.prepareStatement("insert
> into temp1 values(?)");
> preparedStmt.clearParameters();
> preparedStmt.setString(1, msg1);
> preparedStmt.executeUpdate();
> preparedStmt.close();
>
> And it throws an Exception saying "\0 not allowd"what should I do ?
> How should I insert unicode string using jdbc ?

AFAIK, you can't store \0 in a text (varchar, ...) field. This is a
server-side restriction, not a JDBC-specific issue. Any other (16 bit)
unicode character should be fine assuming it can be represented in your
DB encoding.

You may want to use bytea and PreparedStatement.setBytes() if you really
want to store arbitary data.

-O

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message pgsql 2004-08-30 13:50:54 Re: Contrib -- PostgreSQL shared variables
Previous Message chinni 2004-08-30 10:06:37 error with unicode thing??