Contributors Mailing Lists User lists Developer lists Regional lists Associations User groups Project lists pgadmin-hackers pgadmin-support pgsql-jdbc pgsql-odbc pgsql-pkg-debian pgsql-pkg-yum psycopg Inactive lists IRC Featured Users International Sites Propaganda Resources Weekly News Re: [JDBC] é converted in é

Поиск
Список
Период
Сортировка
От dmp
Тема Contributors Mailing Lists User lists Developer lists Regional lists Associations User groups Project lists pgadmin-hackers pgadmin-support pgsql-jdbc pgsql-odbc pgsql-pkg-debian pgsql-pkg-yum psycopg Inactive lists IRC Featured Users International Sites Propaganda Resources Weekly News Re: [JDBC] é converted in é
Дата
Msg-id 5115A7E4.7030505@ttc-cmc.net
обсуждение исходный текст
Ответ на Re: Timestamp vs. Java Date/Timestamp  (dmp <danap@ttc-cmc.net>)
Ответы Re: é converted in é  (dmp <danap@ttc-cmc.net>)
Список pgsql-jdbc
 > 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);
       }
    }


В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Dave Cramer
Дата:
Сообщение: Re: [JDBC] Re: [JDBC] é converted in Ã(c)
Следующее
От: dmp
Дата:
Сообщение: Re: é converted in é