Thread: JDBC and Accents

JDBC and Accents

From
Loïc Courtois
Date:
Hello,

I have some problems to display the accents in my db, using the JDBC and
postgres 7.1.

Apparently, all accents are replaced by a '?'.

Thanks .

Loic Courtois
Netpartage


Re: JDBC and Accents

From
Tony Grant
Date:
Peter can we help in any way with getting the JDBC to work with european character sets??

Such as in testing help with documentation whatever

Cheers

Tony Grant

--
RedHat Linux on Sony Vaio C1XD/S
http://www.animaproductions.com/linux2.html


Re: JDBC and Accents

From
Marko Kreen
Date:
On Fri, Apr 27, 2001 at 01:56:38AM +0200, Loïc Courtois wrote:
> Hello,
>
> I have some problems to display the accents in my db, using the JDBC and
> postgres 7.1.
>
> Apparently, all accents are replaced by a '?'.

What is your database encoding?

You can insert whatever stuff you want into db and
psql displays it fine - it does not care what it is.

But JDBC 7.1 does use database encoding for understanding
stuff it gets and translating it to Java strings.  So if your
db encoding is SQL_ASCII but data is LATIN1 you are screwed.
Same with data in LATIN1 and db in UNICODE.  etc...

--
marko


Re: JDBC and Accents

From
Tony Grant
Date:
On 27 Apr 2001 14:26:14 +0200, Marko Kreen wrote:

>
> What is your database encoding?
>
> You can insert whatever stuff you want into db and
> psql displays it fine - it does not care what it is.
>
> But JDBC 7.1 does use database encoding for understanding
> stuff it gets and translating it to Java strings.  So if your
> db encoding is SQL_ASCII but data is LATIN1 you are screwed.
> Same with data in LATIN1 and db in UNICODE.  etc...

How do I set it?

Searching docs for "database encoding" gives:

Sorry, but search returned no results.

Is this the locale value that can be passed at start up? I will document
this in my Ultradev - Posgresql HOWTO because it is JDBC related.

Cheers

Tony Grant

--
RedHat Linux on Sony Vaio C1XD/S
http://www.animaproductions.com/linux2.html


Re: JDBC and Accents

From
Loïc Courtois
Date:
> On Fri, Apr 27, 2001 at 01:56:38AM +0200, Loïc Courtois wrote:
> > Hello,
> >
> > I have some problems to display the accents in my db, using the JDBC and
> > postgres 7.1.
> >
> > Apparently, all accents are replaced by a '?'.
>
> What is your database encoding?
>
> You can insert whatever stuff you want into db and
> psql displays it fine - it does not care what it is.
>
> But JDBC 7.1 does use database encoding for understanding
> stuff it gets and translating it to Java strings.  So if your
> db encoding is SQL_ASCII but data is LATIN1 you are screwed.
> Same with data in LATIN1 and db in UNICODE.  etc...

My database encoding is SQL_ASCII...

Is there any temporary solutions, or may a convert the db in an other
encoding?

Thanks

Loic Courtois



Re: JDBC and Accents

From
Peter T Mount
Date:
Quoting Tony Grant <tony@animaproductions.com>:

> Peter can we help in any way with getting the JDBC to work with european
> character sets??
>
> Such as in testing help with documentation whatever

In theory it should work when the backend is compiled for Unicode...

PS: JDBC stuff should go to the JDBC list rather than General or Interfaces...

Peter

--
Peter Mount peter@retep.org.uk
PostgreSQL JDBC Driver: http://www.retep.org.uk/postgres/
RetepPDF PDF library for Java: http://www.retep.org.uk/pdf/

Re: JDBC and Accents

From
Tony Grant
Date:
On 27 Apr 2001 14:36:21 +0200, Loïc Courtois wrote:

>
> My database encoding is SQL_ASCII...
>
> Is there any temporary solutions, or may a convert the db in an other
> encoding?

OK j'ai trouvé - en anglais pour la liste

Do a pg_dump of your database

Create a new database with "createdb -E LATIN1 databasename"

Reimport your data.

Cheers

Tony Grant

--
RedHat Linux on Sony Vaio C1XD/S
http://www.animaproductions.com/linux2.html


Re: JDBC and Accents

From
Marko Kreen
Date:
On Fri, Apr 27, 2001 at 02:37:48PM +0200, Tony Grant wrote:
> On 27 Apr 2001 14:26:14 +0200, Marko Kreen wrote:
>
> >
> > What is your database encoding?
> >
> > You can insert whatever stuff you want into db and
> > psql displays it fine - it does not care what it is.
> >
> > But JDBC 7.1 does use database encoding for understanding
> > stuff it gets and translating it to Java strings.  So if your
> > db encoding is SQL_ASCII but data is LATIN1 you are screwed.
> > Same with data in LATIN1 and db in UNICODE.  etc...
>
> How do I set it?

initdb --ecnoding ENC    sets the template* encoding, this gets
    used when you dont specify the encoding in db creation
    time.

CREATE DATABASE xx WITH ECCODING='ENC';
createdb xx --encoding ENC
    same thing, sets the new database encoding.

and there is commands
    SET CLIENT_ENCODING='ENC';
    SET SERVER_ENCODING='ENC';

which set the encoding for one session.  SERVER_ENCODING is
r/o though.  CLIENT_ENCODING Im not so sure, probably
commands the server to do on-the-fly encoding conversion
for client.  I expect this needs correct database encoding...


> Searching docs for "database encoding" gives:
>
> Sorry, but search returned no results.

It _is_ documented somewhere but I cant do much
surfing at the moment coz Iam sitting behind a 80x25 Video
Terminal...

>
> Is this the locale value that can be passed at start up? I will document
> this in my Ultradev - Posgresql HOWTO because it is JDBC related.

Look in docs help for above commands.

--
marko


Re: JDBC and Accents

From
Marko Kreen
Date:
On Fri, Apr 27, 2001 at 02:36:21PM +0200, Loïc Courtois wrote:
> > On Fri, Apr 27, 2001 at 01:56:38AM +0200, Loïc Courtois wrote:
> > > Hello,
> > >
> > > I have some problems to display the accents in my db, using the JDBC and
> > > postgres 7.1.
> > >
> > > Apparently, all accents are replaced by a '?'.
> >
> > What is your database encoding?
> >
> > You can insert whatever stuff you want into db and
> > psql displays it fine - it does not care what it is.

> My database encoding is SQL_ASCII...
>
> Is there any temporary solutions, or may a convert the db in an other
> encoding?

Correct solutions is really dump database, create db with right
encoding and restore.

But for temporary solution ;) you could use PostgreSQL 7.0
JDBC driver, which does not support those db encodings...


--
marko


Re: JDBC and Accents

From
Peter T Mount
Date:
Quoting Tony Grant <tony@animaproductions.com>:

> On 27 Apr 2001 08:52:33 -0400, Peter T Mount wrote:
>
> > In theory it should work when the backend is compiled for Unicode...
> >
> > PS: JDBC stuff should go to the JDBC list rather than General or
> Interfaces...
>
> Sorry! OK I'll subscribe over there

That's ok. I'm trying to get people to use the pgsql-jdbc list instead of
general because of the sheer volume of emails. I'm dropping general as most of
it is of no use for me personally except the JDBC content, and conversely would
save me a lot of time both downloading and reading...

Peter

--
Peter Mount peter@retep.org.uk
PostgreSQL JDBC Driver: http://www.retep.org.uk/postgres/
RetepPDF PDF library for Java: http://www.retep.org.uk/pdf/