pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: dmp <danap@ttc-cmc.net>
To: shivenderd@gmail.com
To: pgsql-jdbc@postgresql.org
Subject: Re: Authentication failed when Password contains Japaneese Charecters
Date: Tue, 20 Apr 2010 19:10:21 -0600
Message-ID: <4BCE507D.3060906@ttc-cmc.net> (raw)
In-Reply-To: <8844.1271809392@sss.pgh.pa.us>
References: <q2ua7ddbfcf1004201711w90e5f323off7afcf12a0fbad4@mail.gmail.com>
	<8844.1271809392@sss.pgh.pa.us>

>
>
>Shivender Devarakonda <shivenderd@gmail.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.



view thread (15+ messages)  latest in thread

Message-ID: <4BCE507D.3060906@ttc-cmc.net>
Permalink:  ../4BCE507D.3060906@ttc-cmc.net/
Also on:    postgresql.org/message-id/4BCE507D.3060906@ttc-cmc.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: danap@ttc-cmc.net, shivenderd@gmail.com
  Subject: Re: Authentication failed when Password contains Japaneese Charecters
  In-Reply-To: <4BCE507D.3060906@ttc-cmc.net>
  References: <q2ua7ddbfcf1004201711w90e5f323off7afcf12a0fbad4@mail.gmail.com> <8844.1271809392@sss.pgh.pa.us> <4BCE507D.3060906@ttc-cmc.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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