Re: German Special Chars (Umlaute)

From: Barry Lind <blind(at)xythos(dot)com>
To: Gunnar Giesinger <mailinglists(at)gmx(dot)at>
Cc: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: German Special Chars (Umlaute)
Date: 2004-05-05 19:38:24
Message-ID: 409942B0.403@xythos.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Gunner,

The jdbc driver always uses unicode as it's character set (since java's
character set internally is unicode). The jdbc driver relies on the
server to convert from LATIN1 to unicode(utf8). This all works
correctly in the jdbc driver. There is something about your environment
or code that is working incorrectly, not the jdbc driver.

That is why I was asking you the questions I did.

To provide you any more help on this, you are going to need to put
together a simple test program that you can email to the lists that
reproduces your problem, so that someone can help you.

thanks,
--Barry

Gunnar Giesinger wrote:
> Barry,
>
> thank you for your quick response!
>
> My problem really seems to result from different encoding settings.
>
> Sending 'executeQuery("select getdatabaseencoding()")' via JDBC to the
> database states 'LATIN1' as the correct database encoding.
>
> On the other hand 'executeQuery("SHOW client_encoding")' over JDBC
> displays 'UNICODE' as client encoding although sending the same query
> via phpPgAdmin indicates 'LATIN1' as character set.
>
> I found a possible solution: executing
> 'con.createStatement().execute("SET CLIENT_ENCODING = 'LATIN1'")' after
> establishing the connection results in 'LATIN1' in the JDBC client too
> and allows a correct displaying of the german umlauts. As my application
> finally should be developed on a tomcat application server and the
> database connection will therefore be handled through connection pooling
> I would have to send this statement each time after requesting a
> connection object from the pool.
>
> Do you know if there is another way to configure the client encoding via
> jdbc or even in a tomcat configuration file? (I've already tried various
> things like adding '?charSet=LATIN1' to the database url or setting
> ("charSet", "LATIN1") in the connection properties).
>
> Thank you!
>
> Gunnar
>
>
> -----Ursprüngliche Nachricht-----
> Von: pgsql-jdbc-owner(at)postgresql(dot)org
> [mailto:pgsql-jdbc-owner(at)postgresql(dot)org] Im Auftrag von Barry Lind
> Gesendet: Mittwoch, 05. Mai 2004 05:22
> An: Gunnar Giesinger
> Cc: pgsql-jdbc(at)postgresql(dot)org
> Betreff: Re: [JDBC] German Special Chars (Umlaute)
>
>
> Gunnar,
>
> There are a variety of things that could be going wrong. But I would
> first suspect the fact that you didn't specify what character set to use
>
> in your System.out.println() calls. Because you didn't specify, java
> will use its default which may or may not be what you want. You also
> don't show how you are getting the data into this table, so the problem
> may be that the data is corrupted while being inserted.
>
> --Barry
>
>
> Gunnar Giesinger wrote:
>
>>hi everybody!
>>
>>I need to set up a database that should be able to contain values that
>
>
>>include German special chars (Umlauts like &Auml;&auml;...). I
>>therefore created a database with 'LATIN1' as character encoding.
>>
>>Afterwards I tried to access a table containing only one character
>>varying field for test purposes via JDBC:
>>
>> Class.forName("org.postgresql.Driver");
>> String url = "jdbc:postgresql://server:5432/umlaute";
>> Properties info = new Properties();
>> info.put("user", "usr");
>> info.put("password", "pw");
>> Connection con = DriverManager.getConnection(url, info);
>> Statement stmt = con.createStatement();
>> ResultSet rst = stmt.executeQuery("SELECT * FROM test");
>> rst.next();
>> System.out.println(rst.getString(1));
>>
>>Everything works fine except instead of all the German special chars
>>strange symbols are displayed.
>>
>>Does anybody know how to fix this problem?
>>
>>Thanks
>>
>>john
>>
>>used system: PostgreSQL 7.3.4 on fedora core 1
>> MS Windows Client
>> various JDBC drivers tested
>>
>>
>>
>>
>>---------------------------(end of
>>broadcast)---------------------------
>>TIP 9: the planner will ignore your desire to choose an index scan if
>
> your
>
>> joining column's datatypes do not match
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>
>

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2004-05-05 19:46:25 Re: Result Set Cursor Patch
Previous Message Kris Jurka 2004-05-05 19:33:40 Re: CLDC implementation of the pgsql driver.