Re: Authentication failed when Password contains Japaneese Charecters

From: dmp <danap(at)ttc-cmc(dot)net>
To: shivenderd(at)gmail(dot)com, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Authentication failed when Password contains Japaneese Charecters
Date: 2010-04-21 01:10:21
Message-ID: 4BCE507D.3060906@ttc-cmc.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

>
>
>Shivender Devarakonda <shivenderd(at)gmail(dot)com> writes:
>
>
>>> I am using Postgres SQL version 8.3 server and I have a client that uses
>>> Postgres SQL JDBC driver. I have a user "admin" with the password having
>>> japaneese charecters å½¢å¼.
>>
>>
>
>Just a guess, but I suspect it's an encoding issue. I expect JDBC would
>send the password in utf8 encoding. Maybe you defined the password in
>a session that was using a different encoding?
>
> regards, tom lane
>
>
>
Encoding I think is the best guess, but I did have a password that
worked perfectly
well with psql but failed in the application using the JDBC. I finally
tracked it down to
a special escape sequence character, %, in the password string created
by a user. You
could check to make sure one of your character encodings does not
translate to one
of these special characters. Solution finally was to translate the
character to a
hexadecimal value. Code follows:

// MySQL, PostgreSQL, & HSQL
else
{
// The % character is interpreted as the start of a special escaped
sequence,
// two digit hexadeciaml value. So replace passwordString characters
with that
// character with that characters hexadecimal value as sequence, %37. Java
// API URLDecoder.

passwordString = passwordString.replaceAll("%", "%" +
Integer.toHexString(37));
connectionProperties += subProtocol + "://" + host + ":" + port + "/" +
db + "?user=" + user
+ "&password=" + passwordString + "&useSSL=" + ssh;
// System.out.println(connectionProperties);
dbConnection = DriverManager.getConnection(connectionProperties)
}

danap.

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Tom Lane 2010-04-21 01:18:01 Re: Authentication failed when Password contains Japaneese Charecters
Previous Message Shivender Devarakonda 2010-04-21 00:35:25 Re: Authentication failed when Password contains Japaneese Charecters