pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
 Re: [JDBC] Re: [JDBC] é converted in Ã(c)
4+ messages / 2 participants
[nested] [flat]

*  Re: [JDBC] Re: [JDBC] é converted in Ã(c)
@ 2013-02-08 23:01  Dave Cramer <pg@fastcrypt.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Dave Cramer @ 2013-02-08 23:01 UTC (permalink / raw)
  To: Kevin Grittner <kgrittn@ymail.com>; +Cc: Laurent Schweizer <laurent.schweizer@peoplefone.com>; pgsql-jdbc

The JDBC driver only knows one encoding. Are you using it to retrieve the
data as well ?

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca


On Fri, Feb 8, 2013 at 5:52 PM, Kevin Grittner <kgrittn@ymail.com> wrote:

> Laurent Schweizer <laurent.schweizer@peoplefone.com> wrote:
>
> > I have an issue with special character like é.
>
> > 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 “é”  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 é is converted in é
> >
> > I have added to the connection string the option:
> > ?useUnicode=true&characterEncoding=utf8
> >
> > And if I do a : "SHOW client_encoding;” 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
>
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc
>

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

*  RE: [JDBC] Re: [JDBC] Re: [JDBC] é converted in Ã(c)
@ 2013-02-09 09:48  Laurent Schweizer <laurent.schweizer@peoplefone.com>
  parent: Dave Cramer <pg@fastcrypt.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Laurent Schweizer @ 2013-02-09 09:48 UTC (permalink / raw)
  To: 'Dave Cramer' <pg@fastcrypt.com>; 'Kevin Grittner' <kgrittn@ymail.com>; +Cc: pgsql-jdbc

I think that I’m correct with the  client encoding as the “SHOW
client_encoding” return UTF8 no ?

 

Laurent

 

De : pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org] De la part de Dave Cramer
Envoyé : samedi 9 février 2013 00:01
À : Kevin Grittner
Cc : Laurent Schweizer; pgsql-jdbc@postgresql.org
Objet : [JDBC] Re: [JDBC] Re: [JDBC] é converted in Ã(c)

 

The JDBC driver only knows one encoding. Are you using it to retrieve the
data as well ?




Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca

 

On Fri, Feb 8, 2013 at 5:52 PM, Kevin Grittner <kgrittn@ymail.com> wrote:

Laurent Schweizer <laurent.schweizer@peoplefone.com> wrote:

> I have an issue with special character like é.

> 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 “é”  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 é is converted in é
>
> I have added to the connection string the option:
> ?useUnicode=true&characterEncoding=utf8
>
> And if I do a : "SHOW client_encoding;” 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


--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

 

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

*  Re: [JDBC] Re: [JDBC] Re: [JDBC] é converted in Ã(c)
@ 2013-02-09 10:48  Dave Cramer <pg@fastcrypt.com>
  parent: Laurent Schweizer <laurent.schweizer@peoplefone.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Dave Cramer @ 2013-02-09 10:48 UTC (permalink / raw)
  To: Laurent Schweizer <laurent.schweizer@peoplefone.com>; +Cc: Kevin Grittner <kgrittn@ymail.com>; pgsql-jdbc

Well as I said the driver only knows one encoding which is UTF8 so I
suspect that the other process is somehow not using TF8

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca


On Sat, Feb 9, 2013 at 4:48 AM, Laurent Schweizer <
laurent.schweizer@peoplefone.com> wrote:

> I think that I’m correct with the  client encoding as the “SHOW
> client_encoding” return UTF8 no ?****
>
> ** **
>
> Laurent****
>
> ** **
>
> *De :* pgsql-jdbc-owner@postgresql.org [mailto:
> pgsql-jdbc-owner@postgresql.org] *De la part de* Dave Cramer
> *Envoyé :* samedi 9 février 2013 00:01
> *À :* Kevin Grittner
> *Cc :* Laurent Schweizer; pgsql-jdbc@postgresql.org
> *Objet :* [JDBC] Re: [JDBC] Re: [JDBC] é converted in Ã(c)****
>
> ** **
>
> The JDBC driver only knows one encoding. Are you using it to retrieve the
> data as well ?****
>
>
> ****
>
> Dave Cramer
>
> dave.cramer(at)credativ(dot)ca
> http://www.credativ.ca****
>
> ** **
>
> On Fri, Feb 8, 2013 at 5:52 PM, Kevin Grittner <kgrittn@ymail.com> wrote:*
> ***
>
> Laurent Schweizer <laurent.schweizer@peoplefone.com> wrote:
>
> > I have an issue with special character like é.
>
> > 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 “é”  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 é is converted in é
> >
> > I have added to the connection string the option:
> > ?useUnicode=true&characterEncoding=utf8
> >
> > And if I do a : "SHOW client_encoding;” 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
>
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc****
>
> ** **
>

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

*  Re: [JDBC] RE: [JDBC] é converted in Ã(c)
@ 2013-02-09 18:08  Dave Cramer <pg@fastcrypt.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Dave Cramer @ 2013-02-09 18:08 UTC (permalink / raw)
  To: Laurent Schweizer <laurent.schweizer@peoplefone.com>; +Cc: pgsql-jdbc

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 box
On 2013-02-09 12:42 PM, "Laurent Schweizer" <
laurent.schweizer@peoplefone.com> 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 = "jdbc:postgresql://
> 95.128.80.38/testchar?useUnicode=true&characterEncoding=utf8";
>       conn = 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 = "SET client_encoding = 'LATIN9';";
>
>
>     String query = "SELECT input FROM test ";
>     try
>     {
>
>       //  Statement st2 = conn.createStatement();
>         // st2.execute(query1);
>       Statement st = conn.createStatement();
>       ResultSet rs = st.executeQuery(query);
>       while (rs.next())
>       {
>         String s = rs.getString(1);
>         System.out.println("val:"+s );
>
>       }
>     }
>     catch (SQLException ex)
>     {
>       System.err.println(ex.getMessage());
>     }
>
>
>     /*
>     String queryup = "UPDATE test set input ='snom 320 é' WHERE id=1";
>     try
>     {
>       Statement st = 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é : samedi 9 février 2013 17:55
> À : Laurent Schweizer; pgsql-jdbc@postgresql.org
> Objet : Re: [JDBC] é converted in é
>
> 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é :
> > samedi 9 février 2013 02:42 À : laurent.schweizer@peoplefone.com;
> > pgsql-jdbc@postgresql.org Objet : Re: [JDBC] é converted in é
> >
> >   >  Laurent Schweizer<laurent(dot)schweizer(at)peoplefone(dot)com>
>  wrote:
> >   >
> >   >  >  I have an issue with special character like é.
> >   >
> >   >  >  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 “é”
> > 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 é is converted in é>  >   >  >  I have added to the connection
> string
> > the option:
> >   >  >  ?useUnicode=true&characterEncoding=utf8
> >   >  >
> >   >  >  And if I do a : "SHOW client_encoding;” 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 = con.createStatement();
> >            con.setAutoCommit(false);
> >
> >            sqlStatementString = "DROP TABLE IF EXISTS jdbc_demo";
> >            sqlStatement.execute(sqlStatementString);
> >
> >            sqlStatementString = "Create Table jdbc_demo (col
> VARCHAR(30))";
> >            sqlStatement.execute(sqlStatementString);
> >
> >            pstmt = con.prepareStatement("INSERT INTO jdbc_demo VALUES
> > (?), (?)");
> >            pstmt.setString(1, "\u0041"); // A
> >            pstmt.setString(2, "\u00E9"); // Acute Latin e
> >            pstmt.execute();
> >
> >            sqlStatementString = "SELECT * FROM jdbc_demo";
> >            sqlStatement.execute(sqlStatementString);
> >
> >            rs = sqlStatement.executeQuery(sqlStatementString);
> >
> >            JPanel panel = new JPanel();
> >
> >            while (rs.next())
> >            {
> >               String dataString = rs.getString("col");
> >               System.out.println("col:" + dataString);
> >               panel.add(new JLabel(dataString));
> >            }
> >            rs.close();
> >
> >            JFrame frame = new JFrame();
> >            frame.getContentPane().add(panel);
> >            frame.setSize(200, 200);
> >            frame.setVisible(true);
> >
> >            sqlStatementString = "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
>

^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2013-02-09 18:08 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-02-08 23:01  Re: [JDBC] Re: [JDBC] é converted in Ã(c) Dave Cramer <pg@fastcrypt.com>
2013-02-09 09:48 ` Laurent Schweizer <laurent.schweizer@peoplefone.com>
2013-02-09 10:48   ` Dave Cramer <pg@fastcrypt.com>
2013-02-09 18:08  Re: [JDBC] RE: [JDBC] é converted in Ã(c) Dave Cramer <pg@fastcrypt.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox