Skip site navigation (1) Skip section navigation (2)

Connection fails when the user name contains chinese characters

From: "Sarkar, Sudipta" <Sudipta_Sarkar(at)bmc(dot)com>
To: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Connection fails when the user name contains chinese characters
Date: 2010-05-17 20:02:21
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
   I have a postgres 8.3 database with a user name containing Chinese characters  泰山.

When I am trying to connect to the database using this user name it fails with the following message:

Exception in thread "main" org.postgresql.util.PSQLException: FATAL: role "??" does not exist
                at org.postgresql.core.v3.ConnectionFactoryImpl.readStartupMessages(
                at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(
                at org.postgresql.core.ConnectionFactory.openConnection(
                at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(
                at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(
                at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(
                at org.postgresql.jdbc4.Jdbc4Connection.<init>(
                at org.postgresql.Driver.makeConnection(
                at org.postgresql.Driver.connect(
                at java.sql.DriverManager.getConnection(
                at java.sql.DriverManager.getConnection(
                at JDBCTest.main(

My code snippet is the following:
      Properties connProp = new Properties();
       connProp.put("user", "\u6cf0\u5c71");  //Set the user name. Need to use Unicode escaped since it contains non ascii characters
       System.out.println("connProp: " + connProp + " " + connProp.getProperty("user"));
       Connection conn = DriverManager.getConnection("jdbc:postgresql://", connProp);

I even tried with DriverManager.getConnection("jdbc:postgresql://", "\u6cf0\u5c71", “”);

Which gives the same error.

Looks like the username is not sent to the server correctly.

I tried to connect to the database using psql -p 15432 -U 泰山 mydb
And the connection was successful.
So the username is correct on the server. The JDBC driver is not sending the user name correctly to the server.

My jdbc version is 8.3-603 and my database encoding is UTF-8.



pgsql-jdbc by date

Next:From: Craig RingerDate: 2010-05-18 02:28:46
Subject: Re: Connection fails when the user name contains chinese characters
Previous:From: Kris JurkaDate: 2010-05-17 18:06:08
Subject: Re: 8.4 vs 8.1 AbstractJdbc2Array - Array retrieval

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group