Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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.


In response to

pgsql-hackers by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group