Обсуждение: Authentication failed when Password contains Japaneese Charecters
Hi all,
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 形式.
Step -1 I used psql client to connect to the Database and it was successful and I am able to see the tables.
Ste-2 Our application uses the JDBC driver to connect to the Database. I see that the password is correctly passed to the
class: org.postgresql.core.v3.ConnectionFactoryImpl
method:doAuthentication
The first statement there
String password = info.getProperty(
returning the "japaneese charecters that I passed.
after that control is going to
case
AUTH_REQ_PASSWORD: block after it flushes the password I see that exception is coming.I see the following log statement in the postgres logs:
[64276-[unknown]-[unknown]-2010-04-20 17:07:56.157 PDT]LOG: connection received: host=138.42.220.183 port=2634
[64276-cemdb-admin-2010-04-20 17:07:56.157 PDT]FATAL: password authentication failed for user "admin"
we use the following JDBC Driver: postgresql-8.4-701.jdbc4.jar
I am not sure why we do not see any problem with psql but we see the problem with JDBC drivers.
Please assist me on this.
Thanks,
Shivender
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
Re: Authentication failed when Password contains Japaneese Charecters
От
Shivender Devarakonda
Дата:
I explicitly changed the property file.encoding to UTF-8 before I run my application. I am sure application is sending the password in UTF-8 byte array[]. Are you talking about server session?
Thanks,
Shivender
On Tue, Apr 20, 2010 at 5:23 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Shivender Devarakonda <shivenderd@gmail.com> writes:Just a guess, but I suspect it's an encoding issue. I expect JDBC would
> 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 形式.
send the password in utf8 encoding. Maybe you defined the password in
a session that was using a different encoding?
regards, tom lane
Re: Authentication failed when Password contains Japaneese Charecters
От
Shivender Devarakonda
Дата:
I did not give any explicit encoding while creating the DB. I am running postgres on Windows XP system.
Thanks for looking in to this.
Regards,
Shivender
On Tue, Apr 20, 2010 at 5:29 PM, Shivender Devarakonda <shivenderd@gmail.com> wrote:
I explicitly changed the property file.encoding to UTF-8 before I run my application. I am sure application is sending the password in UTF-8 byte array[]. Are you talking about server session?Thanks,ShivenderOn Tue, Apr 20, 2010 at 5:23 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:Shivender Devarakonda <shivenderd@gmail.com> writes:Just a guess, but I suspect it's an encoding issue. I expect JDBC would
> 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 形式.
send the password in utf8 encoding. Maybe you defined the password in
a session that was using a different encoding?
regards, tom lane
Shivender Devarakonda <shivenderd@gmail.com> writes: > I did not give any explicit encoding while creating the DB. I am running > postgres on Windows XP system. Well, you should look at what server_encoding is set to, then. If it's not UTF-8 then that's likely the source of the problem. regards, tom lane
> > >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.
Re: Authentication failed when Password contains Japaneese Charecters
От
Shivender Devarakonda
Дата:
Thanks. Where should I look for this property?
Thanks,
Shivender
On Tue, Apr 20, 2010 at 6:18 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Shivender Devarakonda <shivenderd@gmail.com> writes:> I did not give any explicit encoding while creating the DB. I am runningWell, you should look at what server_encoding is set to, then.
> postgres on Windows XP system.
If it's not UTF-8 then that's likely the source of the problem.
regards, tom lane
Re: Authentication failed when Password contains Japaneese Charecters
От
Shivender Devarakonda
Дата:
When I did the psql -l I see the following DBs in my local environment:
C:\PostgreSQL\bin>psql -l
List of databases
Name | Owner | Encoding
-----------+----------+-----------
cmdb | admin | UTF8
postgres | postgres | SQL_ASCII
template0 | postgres | SQL_ASCII
template1 | postgres | SQL_ASCII
List of databases
Name | Owner | Encoding
-----------+----------+-----------
cmdb | admin | UTF8
postgres | postgres | SQL_ASCII
template0 | postgres | SQL_ASCII
template1 | postgres | SQL_ASCII
I am using cmdb which is UTF8.
I think it is consistent with my application? any thoughts what might be wrong.
Thanks,
Shivender
On Tue, Apr 20, 2010 at 7:07 PM, Shivender Devarakonda <shivenderd@gmail.com> wrote:
Thanks. Where should I look for this property?Thanks,Shivender
On Tue, Apr 20, 2010 at 6:18 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:Shivender Devarakonda <shivenderd@gmail.com> writes:> I did not give any explicit encoding while creating the DB. I am runningWell, you should look at what server_encoding is set to, then.
> postgres on Windows XP system.
If it's not UTF-8 then that's likely the source of the problem.
regards, tom lane
Shivender Devarakonda <shivenderd@gmail.com> writes: > When I did the psql -l I see the following DBs in my local environment: > C:\PostgreSQL\bin>psql -l > List of databases > Name | Owner | Encoding > -----------+----------+----------- > cmdb | admin | UTF8 > postgres | postgres | SQL_ASCII > template0 | postgres | SQL_ASCII > template1 | postgres | SQL_ASCII > I am using cmdb which is UTF8. Hmm, but which database did you connect to when you set the user's password? regards, tom lane
I connect to cmdb -Shivender Sent from my iPhone On Apr 20, 2010, at 8:49 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote: > Shivender Devarakonda <shivenderd@gmail.com> writes: >> When I did the psql -l I see the following DBs in my local >> environment: >> C:\PostgreSQL\bin>psql -l >> List of databases >> Name | Owner | Encoding >> -----------+----------+----------- >> cmdb | admin | UTF8 >> postgres | postgres | SQL_ASCII >> template0 | postgres | SQL_ASCII >> template1 | postgres | SQL_ASCII > >> I am using cmdb which is UTF8. > > Hmm, but which database did you connect to when you set the user's > password? > > regards, tom lane
Try change the encoding of sesssions at database nivel to UTF8; this encoding is taked as default for sessions http://www.postgresql.org/docs/8.1/static/sql-alterdatabase.html ; try ALTER DATABASE databasename SET ENCODING TO 'UTF8' (or maybe UFT8 directly). or if this don't work try ALTER DATABASE databasename SET client_encoding TO 'UTF8' or.... from Java set the econding of connections on creation or configuration time (I don't know where exactly, but sure it's possible). Shivender Devarakonda escribió: > > When I did the psql -l I see the following DBs in my local environment: > > C:\PostgreSQL\bin>psql -l > List of databases > Name | Owner | Encoding > -----------+----------+----------- > cmdb | admin | UTF8 > postgres | postgres | SQL_ASCII > template0 | postgres | SQL_ASCII > template1 | postgres | SQL_ASCII > > I am using cmdb which is UTF8. > > I think it is consistent with my application? any thoughts what might > be wrong. > > Thanks, > Shivender > On Tue, Apr 20, 2010 at 7:07 PM, Shivender Devarakonda > <shivenderd@gmail.com <mailto:shivenderd@gmail.com>> wrote: > > Thanks. Where should I look for this property? > > Thanks, > Shivender > > > > > On Tue, Apr 20, 2010 at 6:18 PM, Tom Lane <tgl@sss.pgh.pa.us > <mailto:tgl@sss.pgh.pa.us>> wrote: > > Shivender Devarakonda <shivenderd@gmail.com > <mailto:shivenderd@gmail.com>> writes: > > I did not give any explicit encoding while creating the DB. > I am running > > postgres on Windows XP system. > > Well, you should look at what server_encoding is set to, then. > If it's not UTF-8 then that's likely the source of the problem. > > regards, tom lane > > >
Re: Authentication failed when Password contains Japaneese Charecters
От
Shivender Devarakonda
Дата:
I set the following property in postgresql.conf:
client_encoding = UTF-8 # actually, defaults to database
# encoding
# encoding
I see the same problem after this also...
actaully my DB already shows the encoding format as UTF-8 so according to the comments the client encoding should default to UTF-8.
Please let me know if I miss anything
Thanks,
Shivender
On Tue, Apr 20, 2010 at 9:10 PM, Ader Javier <javierader@gmail.com> wrote:
Try change the encoding of sesssions at database nivel to UTF8; this
encoding is taked as default for sessions
http://www.postgresql.org/docs/8.1/static/sql-alterdatabase.html ; try
ALTER DATABASE databasename SET ENCODING TO 'UTF8'
(or maybe UFT8 directly).
or if this don't work try
ALTER DATABASE databasename SET client_encoding TO 'UTF8'
or.... from Java set the econding of connections on creation or
configuration time (I don't know where exactly, but sure it's possible).
Shivender Devarakonda escribió:
>> When I did the psql -l I see the following DBs in my local environment:
>
> C:\PostgreSQL\bin>psql -l
> List of databases
> Name | Owner | Encoding
> -----------+----------+-----------
> cmdb | admin | UTF8
> postgres | postgres | SQL_ASCII
> template0 | postgres | SQL_ASCII
> template1 | postgres | SQL_ASCII
>
> I am using cmdb which is UTF8.
>
> I think it is consistent with my application? any thoughts what might
> be wrong.
>
> Thanks,
> Shivender
> On Tue, Apr 20, 2010 at 7:07 PM, Shivender Devarakonda> <shivenderd@gmail.com <mailto:shivenderd@gmail.com>> wrote:
>
> Thanks. Where should I look for this property?
>
> Thanks,
> Shivender
>
>
>
>
> On Tue, Apr 20, 2010 at 6:18 PM, Tom Lane <tgl@sss.pgh.pa.us--> <mailto:shivenderd@gmail.com>> writes:
> > I did not give any explicit encoding while creating the DB.
> I am running
> > postgres on Windows XP system.
>
> Well, you should look at what server_encoding is set to, then.
> If it's not UTF-8 then that's likely the source of the problem.
>
> regards, tom lane
>
>
>
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
Shivender Devarakonda <shivenderd@gmail.com> writes: > I set the following property in postgresql.conf: > client_encoding = UTF-8 # actually, defaults to database That would not help if you were connecting to a database with SQL_ASCII encoding (which defeats all encoding intelligence). I'd suggest connecting to cmdb with psql and issuing an ALTER USER command to set the user's password again. regards, tom lane
Re: Authentication failed when Password contains Japaneese Charecters
От
Shivender Devarakonda
Дата:
I did not get you on this. My DB cmdb is in UTF-8 already, do I still need to change the password and test it?
I tried to use ALTER USER to change the password, for some reason the sql command is not displaying the japaneese charecter properly and I tried using the buffer file but the buffer file was default to ANSI format and it is not accepting UTF-8 format..
any thoughts?
Thanks,
Shivender
On Wed, Apr 21, 2010 at 7:58 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Shivender Devarakonda <shivenderd@gmail.com> writes:That would not help if you were connecting to a database with SQL_ASCII
> I set the following property in postgresql.conf:
> client_encoding = UTF-8 # actually, defaults to database
encoding (which defeats all encoding intelligence). I'd suggest
connecting to cmdb with psql and issuing an ALTER USER command to
set the user's password again.
regards, tom lane
Shivender Devarakonda <shivenderd@gmail.com> writes: > I tried to use ALTER USER to change the password, for some reason the sql > command is not displaying the japaneese charecter properly and I tried using > the buffer file but the buffer file was default to ANSI format and it is not > accepting UTF-8 format.. Well, that's sure consistent with the idea that you've got encoding conversion issues going on. I don't know enough about encoding behavior on Windows to help you much more with that. The path of least resistance might be to use a plain-ASCII password. regards, tom lane