Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U4FIT-0002ku-T2 for pgsql-jdbc@arkaria.postgresql.org; Sat, 09 Feb 2013 18:37:10 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U4FIT-0002sH-Ci for pgsql-jdbc@arkaria.postgresql.org; Sat, 09 Feb 2013 18:37:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U4FIS-0002sB-EO for pgsql-jdbc@postgresql.org; Sat, 09 Feb 2013 18:37:08 +0000 Received: from outbound.vnet-inc.com ([216.146.104.103]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U4FIO-0000EI-T2 for pgsql-jdbc@postgresql.org; Sat, 09 Feb 2013 18:37:08 +0000 Received: from [192.168.157.132] (unknown [76.75.27.41]) by outbound.vnet-inc.com (Postfix) with ESMTP id C6AD15965; Sat, 9 Feb 2013 11:37:05 -0700 (MST) Message-ID: <51169711.4030906@ttc-cmc.net> Date: Sat, 09 Feb 2013 11:36:01 -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: Dave Cramer , pgsql-jdbc@postgresql.org Subject: Re: =?windows-1252?Q?=E9_converted_in_=C3=28c=29?= References: In-Reply-To: Content-Type: text/plain; charset=windows-1252; 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 Dave, That is exaclty what I suspect also, just like you guys have already indicated. This is not a pgJDBC issue. danap. Dave Cramer wrote: > I am thinking that it is the printing that is changing the character. > From your test the server is not local what is the locale of the Linux b= ox > > On 2013-02-09 12:42 PM, "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 > { > > Class.forName("org.postgresql.Driver").newInstance(); > String url =3D > "jdbc:postgresql://95.128.80.38/testchar?useUnicode=3Dtrue&characterE= ncoding=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 > { > > // 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 =E9' WHER= E 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=E9 : samedi 9 f=E9vrier 2013 17:55 > =C0 : Laurent Schweizer; pgsql-jdbc@postgresql.org > > Objet : Re: [JDBC] =E9 converted in =C3=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 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=E9 : > > samedi 9 f=E9vrier 2013 02:42 =C0 : laurent.schweizer@peoplefone.c= om > ; > > pgsql-jdbc@postgresql.org > Objet : 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 La= tin > > 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 V= ALUES > > (?), (?)"); > > 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 changes to your > subscription: > http://www.postgresql.org/mailpref/pgsql-jdbc > > > > -- > 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