From laurent.schweizer@peoplefone.com Fri Feb 8 20:32:58 2013 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U3ud0-0005Hv-6G for pgsql-jdbc@arkaria.postgresql.org; Fri, 08 Feb 2013 20:32:58 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U3ucz-00035c-Lz for pgsql-jdbc@arkaria.postgresql.org; Fri, 08 Feb 2013 20:32:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U3ucy-00034k-Fp for pgsql-jdbc@postgresql.org; Fri, 08 Feb 2013 20:32:56 +0000 Received: from mxout001.mail.hostpoint.ch ([2a00:d70:0:e::321]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U3ucw-0005rs-Cf for pgsql-jdbc@postgresql.org; Fri, 08 Feb 2013 20:32:56 +0000 Received: from [10.0.2.10] (helo=asmtp001.mail.hostpoint.ch) by mxout001.mail.hostpoint.ch with esmtp (Exim 4.72 (FreeBSD)) (envelope-from ) id 1U3ucv-000Bdw-FT for pgsql-jdbc@postgresql.org; Fri, 08 Feb 2013 21:32:53 +0100 Received: from [46.14.122.181] (helo=laurentTHINK) by asmtp001.mail.hostpoint.ch with esmtpa (Exim 4.72 (FreeBSD)) (envelope-from ) id 1U3ucu-000Aip-Mz for pgsql-jdbc@postgresql.org; Fri, 08 Feb 2013 21:32:53 +0100 X-Authenticated-Sender-Id: laurent.schweizer@peoplefone.com From: "Laurent Schweizer" To: Subject: =?iso-8859-1?Q?=E9_converted_in_=C3=A9_?= Date: Fri, 8 Feb 2013 21:32:58 +0100 Message-ID: <002d01ce063b$7be0f2e0$73a2d8a0$@peoplefone.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_002E_01CE0643.DDA64540" X-Mailer: Microsoft Outlook 14.0 Content-Language: fr-ch Thread-Index: Ac4GOr2WoNfda3e0TWuJF9NUzQkltQ== X-Pg-Spam-Score: 0.8 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org This is a multipart message in MIME format. ------=_NextPart_000_002E_01CE0643.DDA64540 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Dear all, =20 I have an issue with special character like =E9. =20 I have as server postgres 9.2, I have created a new DB , encoding utf8 =20 =20 Client is a very simple test class that: 1) update a varchar value=20 2) read the same value and print them =20 If I update the varchar with a special character like =93=E9=94 the = value in the DB is correct ( I check them with another software ) but when I read = them from my simple java class the value is not correct and the =E9 is = converted in =C3=A9 =20 I have added to the connection string the option: ?useUnicode=3Dtrue&characterEncoding=3Dutf8 =20 And if I do a : "SHOW client_encoding;=94 I get UTF8 =20 I check on the network side and the =E9 is correctly encoded in UTF-8 =20 Any idea why the =E9 is converted in =C3=A9 ? =20 I use the last version of the JDBC driver. =20 Thanks and regards =20 Laurent ------=_NextPart_000_002E_01CE0643.DDA64540 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

Dear all,

 

I have an issue with special character like = =E9.

 

I have as server postgres 9.2, I have created a new DB , = encoding utf8 =A0

 

Client is a very simple test class = that:

1)      = update=A0 a varchar = value

2)      = read the same value = and print them

 

If I update the varchar with a special character like = “=E9”=A0 the value in the DB is correct ( I check them with = another software ) but when I read them from my simple java class=A0 the = value is not correct and the =E9 is converted in = =C3=A9

 

I have added to the connection string the option: = ?useUnicode= =3Dtrue&characterEncoding=3Dutf8

 

And if I do a = : "SHOW = client_encoding;” I get = =A0UTF8

 =

I check on the = network side and the =E9 is correctly encoded in = UTF-8

 =

Any idea why the =E9 is converted in =C3=A9 ?

 

I use the last version of the JDBC = driver.

 

Thanks and regards

 

Laurent

------=_NextPart_000_002E_01CE0643.DDA64540-- From kgrittn@ymail.com Fri Feb 8 22:52:16 2013 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U3wno-0002Nj-9N for pgsql-jdbc@arkaria.postgresql.org; Fri, 08 Feb 2013 22:52:16 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U3wnn-0007WI-Ak for pgsql-jdbc@arkaria.postgresql.org; Fri, 08 Feb 2013 22:52:15 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U3wnm-0007WD-My for pgsql-jdbc@postgresql.org; Fri, 08 Feb 2013 22:52:14 +0000 Received: from nm25-vm0.bullet.mail.bf1.yahoo.com ([98.139.213.156]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U3wnk-0001D6-PI for pgsql-jdbc@postgresql.org; Fri, 08 Feb 2013 22:52:13 +0000 Received: from [98.139.212.149] by nm25.bullet.mail.bf1.yahoo.com with NNFMP; 08 Feb 2013 22:52:12 -0000 Received: from [98.139.212.248] by tm6.bullet.mail.bf1.yahoo.com with NNFMP; 08 Feb 2013 22:52:12 -0000 Received: from [127.0.0.1] by omp1057.mail.bf1.yahoo.com with NNFMP; 08 Feb 2013 22:52:12 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 22255.72573.bm@omp1057.mail.bf1.yahoo.com Received: (qmail 87164 invoked by uid 60001); 8 Feb 2013 22:52:11 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ymail.com; s=s1024; t=1360363931; bh=xjXqWMX75tvpDmryVa4U7yHJSvC0+hMv1j7g/uERKnY=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=jQHrtfDElBOtBh5wr3RFvayPHqIoVlhgPapVLEhACUSBlOGei9vw4F4cDCBA/HGn5LiCw6+xHCU2es/FTyJFpkEvs5EeRcaI8/PFjyBeDPTEAvfiyiwzSQveBvMltbg6At6MjcGeKEnH9OrhW4jibb2phsAt/joDdkv1ySd87iw= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=ymail.com; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=S8eiWnx1dxhvXgzOTUKdPrYEl7NKdMQ189VvaZQkkv0t9S6pCcTzaBMiYPAING95VM9JEintvf0Iwa/KnjvMElTSs9Rnvm/SWpkZvEJ6OWP61GyNsfSfDvQybwlcLQYPuhVlXTbqu5RiR8BFeMdjnm3vF6hpqXdrIDN+lfA/Nzs=; X-YMail-OSG: Yf4nxkgVM1lhFy4dDOXJFY4U8TrMNOVDmKmW2gf6ltEgfEl 11FnZX_8KDXZTzxW5o9mYxOf5Xr7SqrN2gcVApRxk0UYJAHCo4u.4IAxSpvU ndaS91BngUS5dPZpTrJUIYycHUD1p.r5afrkeJdqLfX0jEfqp.mGL8rvs7oW RhBvqm0kBT2NANHMY9RNT_T4LUBvfm3xOArPOh2DePJ_Hrr2y0LKsc0xkR.o P1s9tlFTjzJgp2n2FAzAElWJIZJE8ZOTGRTtYr.sipQS0Z_cUqZALtfpYnoU pZHuhIbdLOYkcQxt8gI8nFC9lTXDEWO5qDwtwLokHIemhUjyG6ICfAGluVbo fVLuXYzWV9jrlmV1CgC5KAejUWfZWaCr9qaFH11r6uCAfRHWtCke2BSFHObF wBi161q3bOru0g6KRXC21NUgt3_PpjM_nAfM9lkhfQuEd3lMVxpT29.hA8GP T9VC6ch.Fx0QXjAH7GU0- Received: from [76.255.19.161] by web162903.mail.bf1.yahoo.com via HTTP; Fri, 08 Feb 2013 14:52:11 PST X-Rocket-MIMEInfo: 001.001, TGF1cmVudCBTY2h3ZWl6ZXIgPGxhdXJlbnQuc2Nod2VpemVyQHBlb3BsZWZvbmUuY29tPiB3cm90ZToKCj4gSSBoYXZlIGFuIGlzc3VlIHdpdGggc3BlY2lhbCBjaGFyYWN0ZXIgbGlrZSDDqS4KCj4gSSBoYXZlIGFzIHNlcnZlciBwb3N0Z3JlcyA5LjIsIEkgaGF2ZSBjcmVhdGVkIGEgbmV3IERCICwgZW5jb2RpbmcKPiB1dGY4IMKgCj4gCj4gQ2xpZW50IGlzIGEgdmVyeSBzaW1wbGUgdGVzdCBjbGFzcyB0aGF0Ogo.IDEpwqDCoMKgwqDCoCB1cGRhdGXCoCBhIHZhcmNoYXIgdmFsdWUKPiAyKcKgwqDCoMKgwqABMAEBAQE- X-Mailer: YahooMailWebService/0.8.132.503 References: <002d01ce063b$7be0f2e0$73a2d8a0$@peoplefone.com> Message-ID: <1360363931.86012.YahooMailNeo@web162903.mail.bf1.yahoo.com> Date: Fri, 8 Feb 2013 14:52:11 -0800 (PST) From: Kevin Grittner Reply-To: Kevin Grittner Subject: =?utf-8?B?UmU6IFtKREJDXSDDqSBjb252ZXJ0ZWQgaW4gw4PCqSA=?= To: Laurent Schweizer , "pgsql-jdbc@postgresql.org" In-Reply-To: <002d01ce063b$7be0f2e0$73a2d8a0$@peoplefone.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: 0.8 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org Laurent Schweizer wrote: > I have an issue with special character like =C3=A9. > I have as server postgres 9.2, I have created a new DB , encoding > utf8 =C2=A0 >=20 > Client is a very simple test class that: > 1)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 update=C2=A0 a varchar value > 2)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 read the same value and print them >=20 > If I update the varchar with a special character like =E2=80=9C=C3=A9=E2= =80=9D=C2=A0 the > value in the DB is correct ( I check them with another software ) > but when I read them from my simple java class=C2=A0 the value is not > correct and the =C3=A9 is converted in =C3=83=C2=A9 >=20 > I have added to the connection string the option: > ?useUnicode=3Dtrue&characterEncoding=3Dutf8 >=20 > And if I do a : "SHOW client_encoding;=E2=80=9D I get=C2=A0 UTF8 It is behaving as though the client is using a character encoding other than UTF8 -- some sort of 8-bit encoding, probably.=C2=A0 You must set client_encoding to match. -Kevin --=20 Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc From laurent.schweizer@peoplefone.com Sat Feb 9 09:53:30 2013 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U477i-0004sQ-4d for pgsql-jdbc@arkaria.postgresql.org; Sat, 09 Feb 2013 09:53:30 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U477h-0000re-Lc for pgsql-jdbc@arkaria.postgresql.org; Sat, 09 Feb 2013 09:53:29 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U477h-0000rZ-4l for pgsql-jdbc@postgresql.org; Sat, 09 Feb 2013 09:53:29 +0000 Received: from mxout004.mail.hostpoint.ch ([2a00:d70:0:e::324]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U477e-0000se-Ey for pgsql-jdbc@postgresql.org; Sat, 09 Feb 2013 09:53:28 +0000 Received: from [10.0.2.20] (helo=asmtp002.mail.hostpoint.ch) by mxout004.mail.hostpoint.ch with esmtp (Exim 4.72 (FreeBSD)) (envelope-from ) id 1U477d-000C3w-WC for pgsql-jdbc@postgresql.org; Sat, 09 Feb 2013 10:53:26 +0100 Received: from [46.14.48.42] (helo=laurentTHINK) by asmtp002.mail.hostpoint.ch with esmtpa (Exim 4.72 (FreeBSD)) (envelope-from ) id 1U477d-000Hrr-48 for pgsql-jdbc@postgresql.org; Sat, 09 Feb 2013 10:53:25 +0100 X-Authenticated-Sender-Id: laurent.schweizer@peoplefone.com From: "Laurent Schweizer" To: References: <1360043227.14635.9.camel@localhost> <1360123883.14635.35.camel@localhost> <51154D4D.5060409@ttc-cmc.net> <5115A7E4.7030505@ttc-cmc.net> <5115A956.5020804@ttc-cmc.net> In-Reply-To: <5115A956.5020804@ttc-cmc.net> Subject: =?iso-8859-1?Q?RE:_=5BJDBC=5D_=E9_converted_in_=C3=A9?= Date: Sat, 9 Feb 2013 10:53:31 +0100 Message-ID: <004a01ce06ab$51c7dcb0$f5579610$@peoplefone.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQDzsNM/RovRHPzTkgYrJ7sVJd5iBQGoDRUTAi52Es8BJzxnBwGrvDIiAfv0U2YCRWRI1ZnOnUbA Content-Language: fr-ch X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org Hello, I see that you directly convert special character , the problem is that with my application data are inserted with another process . When they insert the data in the DB all is ok. I have only an issue with JDBC to get them correctly. Laurent -----Message d'origine----- De=A0: pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc-owner@postgresql.org] De la part de dmp Envoy=E9=A0: samedi 9 f=E9vrier 2013 02:42 =C0=A0: laurent.schweizer@peoplefone.com; pgsql-jdbc@postgresql.org Objet=A0: Re: [JDBC] =E9 converted in =C3=A9 > Laurent Schweizer wrote: > > > I have an issue with special character like =E9. > > > I have as server postgres 9.2, I have created a new DB , encoding > > utf8 > > > > Client is a very simple test class that: > > 1) update a varchar value > > 2) read the same value and print them > > > > If I update the varchar with a special character like =93=E9=94 the = > > value in the DB is correct ( I check them with another software ) > > but when I read them from my simple java class the value is not > > correct and the =E9 is converted in =C3=A9 > > > > I have added to the connection= string the option: > > ?useUnicode=3Dtrue&characterEncoding=3Dutf8 > > > > And if I do a : "SHOW client_encoding;=94 I get UTF8 > > It is behaving as though the client is using a character encoding > other than UTF8 -- some sort of 8-bit encoding, probably. You must > set client_encoding to match. > > -Kevin Hello Laruent, I have tested the following method with the URL parameters you indicated with PostgreSQL 9.0.1 and the latest driver. Both on a linux and windows systems with the same result of the A and the Acute Latin e properly displaying in a system.out and the frame. I suppose it could be modified slightly to also check and update rather than an insert. danap. private void testInsertUTF(Connection con) { // Method Instances String sqlStatementString; Statement sqlStatement; PreparedStatement pstmt; ResultSet rs; try { sqlStatement =3D con.createStatement(); con.setAutoCommit(false); sqlStatementString =3D "DROP TABLE IF EXISTS jdbc_demo"; sqlStatement.execute(sqlStatementString); sqlStatementString =3D "Create Table jdbc_demo (col VARCHAR(30))"; sqlStatement.execute(sqlStatementString); pstmt =3D con.prepareStatement("INSERT INTO jdbc_demo VALUES (?), (?)"); pstmt.setString(1, "\u0041"); // A pstmt.setString(2, "\u00E9"); // Acute Latin e pstmt.execute(); sqlStatementString =3D "SELECT * FROM jdbc_demo"; sqlStatement.execute(sqlStatementString); rs =3D sqlStatement.executeQuery(sqlStatementString); JPanel panel =3D new JPanel(); while (rs.next()) { String dataString =3D rs.getString("col"); System.out.println("col:" + dataString); panel.add(new JLabel(dataString)); } rs.close(); JFrame frame =3D new JFrame(); frame.getContentPane().add(panel); frame.setSize(200, 200); frame.setVisible(true); sqlStatementString =3D "DROP TABLE IF EXISTS jdbc_demo"; sqlStatement.execute(sqlStatementString); sqlStatement.close(); pstmt.close(); con.setAutoCommit(true); } catch (SQLException sqle) { System.out.println("SQL Exeception" + sqle); } } -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc --=20 Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc From danap@ttc-cmc.net Sat Feb 9 16:56:30 2013 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U4Dj4-0002mY-3z for pgsql-jdbc@arkaria.postgresql.org; Sat, 09 Feb 2013 16:56:30 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U4Dj3-0008IK-8v for pgsql-jdbc@arkaria.postgresql.org; Sat, 09 Feb 2013 16:56:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U4Dj2-0008IF-NA for pgsql-jdbc@postgresql.org; Sat, 09 Feb 2013 16:56:28 +0000 Received: from outbound.vnet-inc.com ([216.146.104.103]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U4Diw-00079s-TF for pgsql-jdbc@postgresql.org; Sat, 09 Feb 2013 16:56:27 +0000 Received: from [192.168.157.132] (unknown [76.75.27.41]) by outbound.vnet-inc.com (Postfix) with ESMTP id 443B25865; Sat, 9 Feb 2013 09:56:21 -0700 (MST) Message-ID: <51167F75.5040102@ttc-cmc.net> Date: Sat, 09 Feb 2013 09:55:17 -0700 From: dmp User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.13) Gecko/20100914 SeaMonkey/2.0.8 MIME-Version: 1.0 To: Laurent Schweizer , pgsql-jdbc@postgresql.org Subject: Re: =?UTF-8?B?w6kgY29udmVydGVkIGluIMODwqk=?= References: <1360043227.14635.9.camel@localhost> <1360123883.14635.35.camel@localhost> <51154D4D.5060409@ttc-cmc.net> <5115A7E4.7030505@ttc-cmc.net> <5115A956.5020804@ttc-cmc.net> <004a01ce06ab$51c7dcb0$f5579610$@peoplefone.com> In-Reply-To: <004a01ce06ab$51c7dcb0$f5579610$@peoplefone.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org Hello Laurent, Use the Method provided to compare the two inserts methods, the one I have demostrated and your process. Reply back with the modified method, code, so that we may have a way of duplicating the error you are describing. I modified the Method this morning and used a update on the extended ASCII chararcter and was still able to to a system.out and placement in JLabel to observe the correct results. If you drive to a garage and ask the mechanic to fix your lights on your car because they do not work and he/she turns them on and they work, how do you expect the mechanic to help? Provide sample code demostrating your issue and perhaps help can be more forth comming. danap. Laurent Schweizer wrote: > Hello, > > I see that you directly convert special character , the problem is that > with my application data are inserted with another process . > > When they insert the data in the DB all is ok. I have only an issue with > JDBC to get them correctly. > > Laurent > > > > > -----Message d'origine----- > De : pgsql-jdbc-owner@postgresql.org > [mailto:pgsql-jdbc-owner@postgresql.org] De la part de dmp > Envoy=C3=A9 : samedi 9 f=C3=A9vrier 2013 02:42 > =C3=80 : laurent.schweizer@peoplefone.com; pgsql-jdbc@postgresql.org > Objet : Re: [JDBC] =C3=A9 converted in =C3=83=C2=A9 > > > Laurent Schweizer wrot= e: > > > > > I have an issue with special character like =C3=A9. > > > > > I have as server postgres 9.2, I have created a new DB , encoding= > > > utf8> > > > Client is a very simple test class that: > > > 1) update a varchar value > > > 2) read the same value and print them > > > > > > If I update the varchar with a special character like =E2=80=9C= =C3=A9=E2=80=9D the> > > value in the DB is correct ( I check them with another software )> > but > when I read them from my simple java class the value is not> > correct > and the =C3=A9 is converted in =C3=83=C2=A9> > > > I have added to t= he connection string > the option: > > > ?useUnicode=3Dtrue&characterEncoding=3Dutf8 > > > > > > And if I do a : "SHOW client_encoding;=E2=80=9D I get UTF8> > = It is > behaving as though the client is using a character encoding> other than > UTF8 -- some sort of 8-bit encoding, probably. You must> set > client_encoding to match. > > > > -Kevin > > Hello Laruent, > > I have tested the following method with the URL parameters you indicated > with PostgreSQL 9.0.1 and the latest driver. Both on a linux and windows > systems with the same result of the A and the Acute Latin e properly > displaying in a system.out and the frame. I suppose it could be modified > slightly to also check and update rather than an insert. > > danap. > > private void testInsertUTF(Connection con) > { > // Method Instances > String sqlStatementString; > Statement sqlStatement; > PreparedStatement pstmt; > ResultSet rs; > > try > { > sqlStatement =3D con.createStatement(); > con.setAutoCommit(false); > > sqlStatementString =3D "DROP TABLE IF EXISTS jdbc_demo"; > sqlStatement.execute(sqlStatementString); > > sqlStatementString =3D "Create Table jdbc_demo (col VARCHAR(30= ))"; > sqlStatement.execute(sqlStatementString); > > pstmt =3D con.prepareStatement("INSERT INTO jdbc_demo VALUES (= ?), > (?)"); > pstmt.setString(1, "\u0041"); // A > pstmt.setString(2, "\u00E9"); // Acute Latin e > pstmt.execute(); > > sqlStatementString =3D "SELECT * FROM jdbc_demo"; > sqlStatement.execute(sqlStatementString); > > rs =3D sqlStatement.executeQuery(sqlStatementString); > > JPanel panel =3D new JPanel(); > > while (rs.next()) > { > String dataString =3D rs.getString("col"); > System.out.println("col:" + dataString); > panel.add(new JLabel(dataString)); > } > rs.close(); > > JFrame frame =3D new JFrame(); > frame.getContentPane().add(panel); > frame.setSize(200, 200); > frame.setVisible(true); > > sqlStatementString =3D "DROP TABLE IF EXISTS jdbc_demo"; > sqlStatement.execute(sqlStatementString); > > sqlStatement.close(); > pstmt.close(); > con.setAutoCommit(true); > } > catch (SQLException sqle) > { > System.out.println("SQL Exeception" + sqle); > } > } > > > -- > Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make chan= ges > to your subscription: > http://www.postgresql.org/mailpref/pgsql-jdbc > > > --=20 Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc From laurent.schweizer@peoplefone.com Sat Feb 9 17:42:12 2013 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U4ERI-0006r8-Dg for pgsql-jdbc@arkaria.postgresql.org; Sat, 09 Feb 2013 17:42:12 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U4ERH-0003CM-JM for pgsql-jdbc@arkaria.postgresql.org; Sat, 09 Feb 2013 17:42:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U4ERG-0003CG-MT for pgsql-jdbc@postgresql.org; Sat, 09 Feb 2013 17:42:10 +0000 Received: from mxout004.mail.hostpoint.ch ([2a00:d70:0:e::324]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U4ERD-0007pe-Ex for pgsql-jdbc@postgresql.org; Sat, 09 Feb 2013 17:42:10 +0000 Received: from [10.0.2.20] (helo=asmtp002.mail.hostpoint.ch) by mxout004.mail.hostpoint.ch with esmtp (Exim 4.72 (FreeBSD)) (envelope-from ) id 1U4ERC-0002sz-E0 for pgsql-jdbc@postgresql.org; Sat, 09 Feb 2013 18:42:06 +0100 Received: from [95.128.80.110] (helo=laurentTHINK) by asmtp002.mail.hostpoint.ch with esmtpa (Exim 4.72 (FreeBSD)) (envelope-from ) id 1U4ERB-000O9w-RY for pgsql-jdbc@postgresql.org; Sat, 09 Feb 2013 18:42:06 +0100 X-Authenticated-Sender-Id: laurent.schweizer@peoplefone.com From: "Laurent Schweizer" To: References: <1360043227.14635.9.camel@localhost> <1360123883.14635.35.camel@localhost> <51154D4D.5060409@ttc-cmc.net> <5115A7E4.7030505@ttc-cmc.net> <5115A956.5020804@ttc-cmc.net> <004a01ce06ab$51c7dcb0$f5579610$@peoplefone.com> <51167F75.5040102@ttc-cmc.net> In-Reply-To: <51167F75.5040102@ttc-cmc.net> Subject: =?utf-8?Q?RE:_=5BJDBC=5D_=C3=A9_converted_in_=C3=83=C2=A9?= Date: Sat, 9 Feb 2013 18:42:12 +0100 Message-ID: <007501ce06ec$cb062870$61127950$@peoplefone.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQDzsNM/RovRHPzTkgYrJ7sVJd5iBQGoDRUTAi52Es8BJzxnBwGrvDIiAfv0U2YCRWRI1QKwpmvOAhiH0jWZqNYyYA== Content-Language: fr-ch X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org Dear all, Bellow I have attached the code that I use to do the test, as you can see i= t's very simple. I just do the test on windows (via Eclipse) and encoding is OK !=20 When I run same class on Linux , in command line, the encoding is not OK. Did I need to set some specific parameters on linux ? Regards Laurent import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.Charset; import java.sql.*; public class Testing { Connection conn; /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub new Testing(); } public Testing () { try { =20=20=20=20=09 Class.forName("org.postgresql.Driver").newInstance(); String url =3D "jdbc:postgresql://95.128.80.38/testchar?useUnicode=3D= true&characterEncoding=3Dutf8"; conn =3D DriverManager.getConnection(url, "postgres", ""); doTests(); conn.close(); } catch (ClassNotFoundException ex) {System.err.println(ex.getMessage());} catch (IllegalAccessException ex) {System.err.println(ex.getMessage());} catch (InstantiationException ex) {System.err.println(ex.getMessage());} catch (SQLException ex) {System.err.println(ex.getMessage());} } private void doTests() { doSelectTest(); =20=20=20 } private void doSelectTest() { =20=20=20 // String query1 =3D "SET client_encoding =3D 'LATIN9';"; =20=20=20=20 String query =3D "SELECT input FROM test "; try { =20=20=20=20=09 // Statement st2 =3D conn.createStatement(); // st2.execute(query1); Statement st =3D conn.createStatement(); ResultSet rs =3D st.executeQuery(query); while (rs.next()) { String s =3D rs.getString(1); System.out.println("val:"+s ); =20=20=20=20=20=20=20=20 } } catch (SQLException ex) { System.err.println(ex.getMessage()); } =20=20=20=20 =20=20=20=20 /* String queryup =3D "UPDATE test set input =3D'snom 320 =C3=A9' WHERE id= =3D1"; try { Statement st =3D conn.createStatement(); st.execute(queryup); =20=20=20=20 } catch (SQLException ex) { System.err.println(ex.getMessage()); }*/ =20=20=20=20 } -----Message d'origine----- De : pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc-owner@postgresql.or= g] De la part de dmp Envoy=C3=A9 : samedi 9 f=C3=A9vrier 2013 17:55 =C3=80 : Laurent Schweizer; pgsql-jdbc@postgresql.org Objet : Re: [JDBC] =C3=A9 converted in =C3=83=C2=A9 Hello Laurent, Use the Method provided to compare the two inserts methods, the one I have = demostrated and your process. Reply back with the modified method, code, so= that we may have a way of duplicating the error you are describing. I modified the Method this morning and used a update on the extended ASCII = chararcter and was still able to to a system.out and placement in JLabel to= observe the correct results. If you drive to a garage and ask the mechanic to fix your lights on your ca= r because they do not work and he/she turns them on and they work, how do y= ou expect the mechanic to help? Provide sample code demostrating your issue and perhaps help can be more fo= rth comming. danap. Laurent Schweizer wrote: > Hello, > > I see that you directly convert special character , the problem is=20 > that with my application data are inserted with another process . > > When they insert the data in the DB all is ok. I have only an issue=20 > with JDBC to get them correctly. > > Laurent > > > > > -----Message d'origine----- > De : pgsql-jdbc-owner@postgresql.org > [mailto:pgsql-jdbc-owner@postgresql.org] De la part de dmp Envoy=C3=A9 := =20 > samedi 9 f=C3=A9vrier 2013 02:42 =C3=80 : laurent.schweizer@peoplefone.co= m;=20 > pgsql-jdbc@postgresql.org Objet : Re: [JDBC] =C3=A9 converted in =C3=83= =C2=A9 > > > Laurent Schweizer wrot= e: > > > > > I have an issue with special character like =C3=A9. > > > > > I have as server postgres 9.2, I have created a new DB ,=20 > encoding> > > utf8> > > > Client is a very simple test class that: > > > 1) update a varchar value > > > 2) read the same value and print them > > > > > > If I update the varchar with a special character like =E2=80=9C= =C3=A9=E2=80=9D=20=20 > the> > value in the DB is correct ( I check them with another=20 > software )> > but when I read them from my simple java class the value= is not> > correct > and the =C3=A9 is converted in =C3=83=C2=A9> > > > I have added to t= he connection string > the option: > > > ?useUnicode=3Dtrue&characterEncoding=3Dutf8 > > > > > > And if I do a : "SHOW client_encoding;=E2=80=9D I get UTF8> > = It is > behaving as though the client is using a character encoding> other=20 > than > UTF8 -- some sort of 8-bit encoding, probably. You must> set=20 > client_encoding to match. > > > > -Kevin > > Hello Laruent, > > I have tested the following method with the URL parameters you=20 > indicated with PostgreSQL 9.0.1 and the latest driver. Both on a linux=20 > and windows systems with the same result of the A and the Acute Latin=20 > e properly displaying in a system.out and the frame. I suppose it=20 > could be modified slightly to also check and update rather than an insert. > > danap. > > private void testInsertUTF(Connection con) > { > // Method Instances > String sqlStatementString; > Statement sqlStatement; > PreparedStatement pstmt; > ResultSet rs; > > try > { > sqlStatement =3D con.createStatement(); > con.setAutoCommit(false); > > sqlStatementString =3D "DROP TABLE IF EXISTS jdbc_demo"; > sqlStatement.execute(sqlStatementString); > > sqlStatementString =3D "Create Table jdbc_demo (col VARCHAR(30= ))"; > sqlStatement.execute(sqlStatementString); > > pstmt =3D con.prepareStatement("INSERT INTO jdbc_demo VALUES= =20 > (?), (?)"); > pstmt.setString(1, "\u0041"); // A > pstmt.setString(2, "\u00E9"); // Acute Latin e > pstmt.execute(); > > sqlStatementString =3D "SELECT * FROM jdbc_demo"; > sqlStatement.execute(sqlStatementString); > > rs =3D sqlStatement.executeQuery(sqlStatementString); > > JPanel panel =3D new JPanel(); > > while (rs.next()) > { > String dataString =3D rs.getString("col"); > System.out.println("col:" + dataString); > panel.add(new JLabel(dataString)); > } > rs.close(); > > JFrame frame =3D new JFrame(); > frame.getContentPane().add(panel); > frame.setSize(200, 200); > frame.setVisible(true); > > sqlStatementString =3D "DROP TABLE IF EXISTS jdbc_demo"; > sqlStatement.execute(sqlStatementString); > > sqlStatement.close(); > pstmt.close(); > con.setAutoCommit(true); > } > catch (SQLException sqle) > { > System.out.println("SQL Exeception" + sqle); > } > } > > > -- > Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make=20 > changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-jdbc > > > -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make change= s to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc --=20 Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc From danap@ttc-cmc.net Sat Feb 9 18:34:04 2013 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U4FFU-0002Sk-Mt for pgsql-jdbc@arkaria.postgresql.org; Sat, 09 Feb 2013 18:34:04 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U4FFU-0002Kt-4I for pgsql-jdbc@arkaria.postgresql.org; Sat, 09 Feb 2013 18:34:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U4FFT-0002Ko-CR for pgsql-jdbc@postgresql.org; Sat, 09 Feb 2013 18:34:03 +0000 Received: from outbound.vnet-inc.com ([216.146.104.103]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U4FFO-00009i-AZ for pgsql-jdbc@postgresql.org; Sat, 09 Feb 2013 18:34:02 +0000 Received: from [192.168.157.132] (unknown [76.75.27.41]) by outbound.vnet-inc.com (Postfix) with ESMTP id B2BA65982; Sat, 9 Feb 2013 11:33:57 -0700 (MST) Message-ID: <51169655.3010501@ttc-cmc.net> Date: Sat, 09 Feb 2013 11:32:53 -0700 From: dmp User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.13) Gecko/20100914 SeaMonkey/2.0.8 MIME-Version: 1.0 To: Laurent Schweizer , pgsql-jdbc@postgresql.org Subject: Re: RE: [JDBC] =?UTF-8?B?w6kgY29udmVydGVkIGluIMODwqk=?= References: <1360043227.14635.9.camel@localhost> <1360123883.14635.35.camel@localhost> <51154D4D.5060409@ttc-cmc.net> <5115A7E4.7030505@ttc-cmc.net> <5115A956.5020804@ttc-cmc.net> <004a01ce06ab$51c7dcb0$f5579610$@peoplefone.com> <51167F75.5040102@ttc-cmc.net> <007501ce06ec$cb062870$61127950$@peoplefone.com> In-Reply-To: <007501ce06ec$cb062870$61127950$@peoplefone.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org Hello Laurent, I indicated that I have demostrated with the Test Method I posting a functional sample code that does not produce the result you are indicating on both a Windows and Linux platform. The code you posted is useless. Show us your insertion process with a valid test case like I have demostrated. danap. Laurent Schweizer wrote: > Dear all, > > Bellow I have attached the code that I use to do the test, as you can see= it's very simple. > > I just do the test on windows (via Eclipse) and encoding is OK ! > When I run same class on Linux , in command line, the encoding is not OK. > > Did I need to set some specific parameters on linux ? > > Regards > > Laurent > > > > import java.io.UnsupportedEncodingException; > import java.nio.ByteBuffer; > import java.nio.CharBuffer; > import java.nio.charset.Charset; > import java.sql.*; > public class Testing { > > Connection conn; > /** > * @param args > */ > public static void main(String[] args) { > // TODO Auto-generated method stub > new Testing(); > > } > > > > public Testing () > { > try > { >=20=20=20=20=20=20=09 > Class.forName("org.postgresql.Driver").newInstance(); > String url =3D "jdbc:postgresql://95.128.80.38/testchar?useUnicode= =3Dtrue&characterEncoding=3Dutf8"; > conn =3D DriverManager.getConnection(url, "postgres", ""); > doTests(); > conn.close(); > } > catch (ClassNotFoundException ex) {System.err.println(ex.getMessage(= ));} > catch (IllegalAccessException ex) {System.err.println(ex.getMessage(= ));} > catch (InstantiationException ex) {System.err.println(ex.getMessage(= ));} > catch (SQLException ex) {System.err.println(ex.getMessage(= ));} > } > > private void doTests() > { > doSelectTest(); > > > } > > private void doSelectTest() > { > > // String query1 =3D "SET client_encoding =3D 'LATIN9';"; > > > String query =3D "SELECT input FROM test "; > try > { >=20=20=20=20=20=20=09 > // Statement st2 =3D conn.createStatement(); > // st2.execute(query1); > Statement st =3D conn.createStatement(); > ResultSet rs =3D st.executeQuery(query); > while (rs.next()) > { > String s =3D rs.getString(1); > System.out.println("val:"+s ); > > } > } > catch (SQLException ex) > { > System.err.println(ex.getMessage()); > } > > > /* > String queryup =3D "UPDATE test set input =3D'snom 320 =C3=A9' WHERE= id=3D1"; > try > { > Statement st =3D conn.createStatement(); > st.execute(queryup); > > } > catch (SQLException ex) > { > System.err.println(ex.getMessage()); > }*/ > > } > > -----Message d'origine----- > De : pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc-owner@postgresql.= org] De la part de dmp > Envoy=C3=A9 : samedi 9 f=C3=A9vrier 2013 17:55 > =C3=80 : Laurent Schweizer; pgsql-jdbc@postgresql.org > Objet : Re: [JDBC] =C3=A9 converted in =C3=83=C2=A9 > > Hello Laurent, > > Use the Method provided to compare the two inserts methods, the one I hav= e demostrated and your process. Reply back with the modified method, code, = so that we may have a way of duplicating the error you are describing. > > I modified the Method this morning and used a update on the extended ASCI= I chararcter and was still able to to a system.out and placement in JLabel = to observe the correct results. > > If you drive to a garage and ask the mechanic to fix your lights on your = car because they do not work and he/she turns them on and they work, how do= you expect the mechanic to help? > > Provide sample code demostrating your issue and perhaps help can be more = forth comming. > > danap. > > Laurent Schweizer wrote: >> Hello, >> >> I see that you directly convert special character , the problem is >> that with my application data are inserted with another process . >> >> When they insert the data in the DB all is ok. I have only an issue >> with JDBC to get them correctly. >> >> Laurent >> >> >> -----Message d'origine----- >> De : pgsql-jdbc-owner@postgresql.org >> [mailto:pgsql-jdbc-owner@postgresql.org] De la part de dmp Envoy=C3=A9 : >> samedi 9 f=C3=A9vrier 2013 02:42 =C3=80 : laurent.schweizer@peoplefone.c= om; >> pgsql-jdbc@postgresql.org Objet : Re: [JDBC] =C3=A9 converted in =C3=83= =C2=A9 >> >> > Laurent Schweizer = wrote: >> > >> > > I have an issue with special character like =C3=A9. >> > >> > > I have as server postgres 9.2, I have created a new DB , >> encoding> > >> utf8> > > > Client is a very simple test class that: >> > > 1) update a varchar value >> > > 2) read the same value and print them >> > > >> > > If I update the varchar with a special character like =E2=80= =9C=C3=A9=E2=80=9D >> the> > value in the DB is correct ( I check them with another >> software )> > but when I read them from my simple java class the va= lue is not> > correct >> and the =C3=A9 is converted in =C3=83=C2=A9> > > > I have added= to the connection string >> the option: >> > > ?useUnicode=3Dtrue&characterEncoding=3Dutf8 >> > > >> > > And if I do a : "SHOW client_encoding;=E2=80=9D I get UTF8> = > It is >> behaving as though the client is using a character encoding> other >> than >> UTF8 -- some sort of 8-bit encoding, probably. You must> set >> client_encoding to match. >> > >> > -Kevin >> >> Hello Laruent, >> >> I have tested the following method with the URL parameters you >> indicated with PostgreSQL 9.0.1 and the latest driver. Both on a linux >> and windows systems with the same result of the A and the Acute Latin >> e properly displaying in a system.out and the frame. I suppose it >> could be modified slightly to also check and update rather than an inser= t. >> >> danap. >> >> private void testInsertUTF(Connection con) >> { >> // Method Instances >> String sqlStatementString; >> Statement sqlStatement; >> PreparedStatement pstmt; >> ResultSet rs; >> >> try >> { >> sqlStatement =3D con.createStatement(); >> con.setAutoCommit(false); >> >> sqlStatementString =3D "DROP TABLE IF EXISTS jdbc_demo"; >> sqlStatement.execute(sqlStatementString); >> >> sqlStatementString =3D "Create Table jdbc_demo (col VARCHAR(= 30))"; >> sqlStatement.execute(sqlStatementString); >> >> pstmt =3D con.prepareStatement("INSERT INTO jdbc_demo VALUES >> (?), (?)"); >> pstmt.setString(1, "\u0041"); // A >> pstmt.setString(2, "\u00E9"); // Acute Latin e >> pstmt.execute(); >> >> sqlStatementString =3D "SELECT * FROM jdbc_demo"; >> sqlStatement.execute(sqlStatementString); >> >> rs =3D sqlStatement.executeQuery(sqlStatementString); >> >> JPanel panel =3D new JPanel(); >> >> while (rs.next()) >> { >> String dataString =3D rs.getString("col"); >> System.out.println("col:" + dataString); >> panel.add(new JLabel(dataString)); >> } >> rs.close(); >> >> JFrame frame =3D new JFrame(); >> frame.getContentPane().add(panel); >> frame.setSize(200, 200); >> frame.setVisible(true); >> >> sqlStatementString =3D "DROP TABLE IF EXISTS jdbc_demo"; >> sqlStatement.execute(sqlStatementString); >> >> sqlStatement.close(); >> pstmt.close(); >> con.setAutoCommit(true); >> } >> catch (SQLException sqle) >> { >> System.out.println("SQL Exeception" + sqle); >> } >> } >> >> >> -- >> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make >> changes to your subscription: >> http://www.postgresql.org/mailpref/pgsql-jdbc >> > -- > Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make chan= ges to your subscription: > http://www.postgresql.org/mailpref/pgsql-jdbc --=20 Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc From gc@mnc.ch Mon Feb 11 08:37:45 2013 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U4otU-0003AA-Tu for pgsql-jdbc@arkaria.postgresql.org; Mon, 11 Feb 2013 08:37:45 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U4otU-0002bq-Au for pgsql-jdbc@arkaria.postgresql.org; Mon, 11 Feb 2013 08:37:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U4otT-0002bl-L2 for pgsql-jdbc@postgresql.org; Mon, 11 Feb 2013 08:37:43 +0000 Received: from 62-2-77-205.static.cablecom.ch ([62.2.77.205] helo=mail.mnc.ch) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U4otO-0001WN-BP for pgsql-jdbc@postgresql.org; Mon, 11 Feb 2013 08:37:42 +0000 Received: from localhost (kolab.op.lan [127.0.0.1]) by mail.mnc.ch (Postfix) with ESMTP id 6A56C66B30; Mon, 11 Feb 2013 09:37:35 +0100 (CET) X-Virus-Scanned: by amavisd-new at mnc.ch Received: from mail.mnc.ch ([127.0.0.1]) by localhost (mail.mnc.ch [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id V-KVrHlq8YEV; Mon, 11 Feb 2013 09:37:34 +0100 (CET) Received: from localhost (kolab.op.lan [127.0.0.1]) by mail.mnc.ch (Postfix) with ESMTP id 4A9F166B32; Mon, 11 Feb 2013 09:37:34 +0100 (CET) Received: from gc.localdomain (62-2-77-204.static.cablecom.ch [62.2.77.204]) by mail.mnc.ch (Postfix) with ESMTP id 3538066B30; Mon, 11 Feb 2013 09:37:34 +0100 (CET) Received: by gc.localdomain (Postfix, from userid 500) id 16B3C1874C8; Mon, 11 Feb 2013 09:37:33 +0100 (CET) To: "Laurent Schweizer" Cc: Subject: Re: RE: [JDBC] =?iso-8859-1?Q?=E9?= converted in =?iso-8859-1?Q?=C3=A9?= References: <1360043227.14635.9.camel@localhost> <1360123883.14635.35.camel@localhost> <51154D4D.5060409@ttc-cmc.net> <5115A7E4.7030505@ttc-cmc.net> <5115A956.5020804@ttc-cmc.net> <004a01ce06ab$51c7dcb0$f5579610$@peoplefone.com> <51167F75.5040102@ttc-cmc.net> <007501ce06ec$cb062870$61127950$@peoplefone.com> From: Guillaume Cottenceau X-Hashcash: 1:21:130211:laurent.schweizer@peoplefone.com::ISpTpDsP+KEcu5jw:000000000000000000000000000007ecI X-Hashcash: 1:21:130211:pgsql-jdbc@postgresql.org::6ebWbcp31NT0i/1l:000000000000000000000000000000000000P1yt Date: Mon, 11 Feb 2013 09:37:32 +0100 In-Reply-To: <007501ce06ec$cb062870$61127950$@peoplefone.com> (Laurent Schweizer's message of "Sat\, 9 Feb 2013 18\:42\:12 +0100") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org "Laurent Schweizer" writes: > Dear all, > > Bellow I have attached the code that I use to do the test, as you can see= it's very simple. > > I just do the test on windows (via Eclipse) and encoding is OK !=20 > When I run same class on Linux , in command line, the encoding is not OK. > > Did I need to set some specific parameters on linux ? If your tests are based on printing, you are not sure if your encoding is ok is no places, I guess your insert/update might also be using fixed string from sourcecode, which isn't much reliable either. Your data might even be wrong in the DB. At least in your test, which is based on System.out.println which will work differently based on the default encoding of your system, pipe to hexdump -C and check 0xc3 0xa9 is returned where the =C3=A9 character should be. It would indicate everything works well. > Regards > > Laurent > > > > import java.io.UnsupportedEncodingException; > import java.nio.ByteBuffer; > import java.nio.CharBuffer; > import java.nio.charset.Charset; > import java.sql.*; > public class Testing { > > Connection conn; > /** > * @param args > */ > public static void main(String[] args) { > // TODO Auto-generated method stub > new Testing(); > > } > > > > public Testing () > { > try > { >=20=20=20=20=20=09 > Class.forName("org.postgresql.Driver").newInstance(); > String url =3D "jdbc:postgresql://95.128.80.38/testchar?useUnicode= =3Dtrue&characterEncoding=3Dutf8"; > conn =3D DriverManager.getConnection(url, "postgres", ""); > doTests(); > conn.close(); > } > catch (ClassNotFoundException ex) {System.err.println(ex.getMessage()= );} > catch (IllegalAccessException ex) {System.err.println(ex.getMessage()= );} > catch (InstantiationException ex) {System.err.println(ex.getMessage()= );} > catch (SQLException ex) {System.err.println(ex.getMessage()= );} > } > > private void doTests() > { > doSelectTest(); > >=20=20=20=20 > } > > private void doSelectTest() > { >=20=20=20=20 > // String query1 =3D "SET client_encoding =3D 'LATIN9';"; >=20=20=20=20=20 > > String query =3D "SELECT input FROM test "; > try > { >=20=20=20=20=20=09 > // Statement st2 =3D conn.createStatement(); > // st2.execute(query1); > Statement st =3D conn.createStatement(); > ResultSet rs =3D st.executeQuery(query); > while (rs.next()) > { > String s =3D rs.getString(1); > System.out.println("val:"+s ); >=20=20=20=20=20=20=20=20=20 > } > } > catch (SQLException ex) > { > System.err.println(ex.getMessage()); > } >=20=20=20=20=20 >=20=20=20=20=20 > /* > String queryup =3D "UPDATE test set input =3D'snom 320 =C3=A9' WHERE = id=3D1"; > try > { > Statement st =3D conn.createStatement(); > st.execute(queryup); >=20=20=20=20=20 > } > catch (SQLException ex) > { > System.err.println(ex.getMessage()); > }*/ >=20=20=20=20=20 > } > > -----Message d'origine----- > De : pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc-owner@postgresql.= org] De la part de dmp > Envoy=C3=A9 : samedi 9 f=C3=A9vrier 2013 17:55 > =C3=80 : Laurent Schweizer; pgsql-jdbc@postgresql.org > Objet : Re: [JDBC] =C3=A9 converted in =C3=83=C2=A9 > > Hello Laurent, > > Use the Method provided to compare the two inserts methods, the one I hav= e demostrated and your process. Reply back with the modified method, code, = so that we may have a way of duplicating the error you are describing. > > I modified the Method this morning and used a update on the extended ASCI= I chararcter and was still able to to a system.out and placement in JLabel = to observe the correct results. > > If you drive to a garage and ask the mechanic to fix your lights on your = car because they do not work and he/she turns them on and they work, how do= you expect the mechanic to help? > > Provide sample code demostrating your issue and perhaps help can be more = forth comming. > > danap. > > Laurent Schweizer wrote: >> Hello, >> >> I see that you directly convert special character , the problem is=20 >> that with my application data are inserted with another process . >> >> When they insert the data in the DB all is ok. I have only an issue=20 >> with JDBC to get them correctly. >> >> Laurent >> >> >> >> >> -----Message d'origine----- >> De : pgsql-jdbc-owner@postgresql.org >> [mailto:pgsql-jdbc-owner@postgresql.org] De la part de dmp Envoy=C3=A9 := =20 >> samedi 9 f=C3=A9vrier 2013 02:42 =C3=80 : laurent.schweizer@peoplefone.c= om;=20 >> pgsql-jdbc@postgresql.org Objet : Re: [JDBC] =C3=A9 converted in =C3=83= =C2=A9 >> >> > Laurent Schweizer wro= te: >> > >> > > I have an issue with special character like =C3=A9. >> > >> > > I have as server postgres 9.2, I have created a new DB ,=20 >> encoding> > >> utf8> > > > Client is a very simple test class that: >> > > 1) update a varchar value >> > > 2) read the same value and print them >> > > >> > > If I update the varchar with a special character like =E2=80=9C= =C3=A9=E2=80=9D=20=20 >> the> > value in the DB is correct ( I check them with another=20 >> software )> > but when I read them from my simple java class the valu= e is not> > correct >> and the =C3=A9 is converted in =C3=83=C2=A9> > > > I have added to = the connection string >> the option: >> > > ?useUnicode=3Dtrue&characterEncoding=3Dutf8 >> > > >> > > And if I do a : "SHOW client_encoding;=E2=80=9D I get UTF8> >= It is >> behaving as though the client is using a character encoding> other=20 >> than >> UTF8 -- some sort of 8-bit encoding, probably. You must> set=20 >> client_encoding to match. >> > >> > -Kevin >> >> Hello Laruent, >> >> I have tested the following method with the URL parameters you=20 >> indicated with PostgreSQL 9.0.1 and the latest driver. Both on a linux= =20 >> and windows systems with the same result of the A and the Acute Latin=20 >> e properly displaying in a system.out and the frame. I suppose it=20 >> could be modified slightly to also check and update rather than an inser= t. >> >> danap. >> >> private void testInsertUTF(Connection con) >> { >> // Method Instances >> String sqlStatementString; >> Statement sqlStatement; >> PreparedStatement pstmt; >> ResultSet rs; >> >> try >> { >> sqlStatement =3D con.createStatement(); >> con.setAutoCommit(false); >> >> sqlStatementString =3D "DROP TABLE IF EXISTS jdbc_demo"; >> sqlStatement.execute(sqlStatementString); >> >> sqlStatementString =3D "Create Table jdbc_demo (col VARCHAR(3= 0))"; >> sqlStatement.execute(sqlStatementString); >> >> pstmt =3D con.prepareStatement("INSERT INTO jdbc_demo VALUES= =20 >> (?), (?)"); >> pstmt.setString(1, "\u0041"); // A >> pstmt.setString(2, "\u00E9"); // Acute Latin e >> pstmt.execute(); >> >> sqlStatementString =3D "SELECT * FROM jdbc_demo"; >> sqlStatement.execute(sqlStatementString); >> >> rs =3D sqlStatement.executeQuery(sqlStatementString); >> >> JPanel panel =3D new JPanel(); >> >> while (rs.next()) >> { >> String dataString =3D rs.getString("col"); >> System.out.println("col:" + dataString); >> panel.add(new JLabel(dataString)); >> } >> rs.close(); >> >> JFrame frame =3D new JFrame(); >> frame.getContentPane().add(panel); >> frame.setSize(200, 200); >> frame.setVisible(true); >> >> sqlStatementString =3D "DROP TABLE IF EXISTS jdbc_demo"; >> sqlStatement.execute(sqlStatementString); >> >> sqlStatement.close(); >> pstmt.close(); >> con.setAutoCommit(true); >> } >> catch (SQLException sqle) >> { >> System.out.println("SQL Exeception" + sqle); >> } >> } >> >> >> -- >> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make=20 >> changes to your subscription: >> http://www.postgresql.org/mailpref/pgsql-jdbc >> >> >> > > > > -- > Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make chan= ges to your subscription: > http://www.postgresql.org/mailpref/pgsql-jdbc --=20 Guillaume Cottenceau --=20 Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc