Re: Authentication failed when Password contains Japaneese Charecters
От | dmp |
---|---|
Тема | Re: Authentication failed when Password contains Japaneese Charecters |
Дата | |
Msg-id | 4BCE507D.3060906@ttc-cmc.net обсуждение исходный текст |
Ответ на | Re: Authentication failed when Password contains Japaneese Charecters (Tom Lane <tgl@sss.pgh.pa.us>) |
Список | pgsql-jdbc |
> > >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.
В списке pgsql-jdbc по дате отправления: