Обсуждение: Re: About a JDBC error

Поиск
Список
Период
Сортировка

Re: About a JDBC error

От
Oliver Jowett
Дата:
zhang-x@cnt.mxy.nes.nec.co.jp wrote:
> Hi all,
>
> I have got this error.
> How can I do with this error?
> I have no idea.

What version of the driver are you using? I see this in the CVS logs:

> ----------------------------
> revision 1.31
> date: 2004/02/10 01:56:46;  author: jurka;  state: Exp;  lines: +14 -6
> Don't try to turn the random bytes from a md5 salt into a String
> because it may not be a valid String depending on the encoding.
>
> Per report from Nadeem Bitar.
> ----------------------------

so if your driver is older than that, it may be the problem.

Failing that, are you using crypt-based authentication? ("crypt" in the
appropriate access line in pg_hba.conf). From a quick glance at the code
it looks like the crypt salt suffers from the same problem as md5 used
to -- it tries to turn a couple of bytes into a String using the default
encoding, which will not work reliably. As a temporary workaround, try
changing pg_hba.conf to use "md5" instead of "crypt".

If you use a different default encoding such as ISO-8859-1 (IIRC you can
do this by setting the file.encoding system property, i.e.
-Dfile.encoding=ISO-8859-1) does the problem go away?

> ----------------err----------------------
> DBAccess.getConnection(): Something unusual has occured to cause the driver
> to fail. Please report this exception: Exception:
> java.lang.IllegalArgumentException
> Stack Trace:
>
> java.lang.IllegalArgumentException
>  at java.nio.Buffer.position(Buffer.java:218)
>  at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:575)
>  at java.lang.StringCoding$CharsetSD.decode(StringCoding.java:186)
>  at java.lang.StringCoding.decode(StringCoding.java:224)
>  at java.lang.StringCoding.decode(StringCoding.java:230)
>  at java.lang.String.<init>(String.java:371)
>  at
> org.postgresql.jdbc1.AbstractJdbc1Connection.openConnectionV2(AbstractJdbc1C
> onnection.java:634)

-O

Re: About a JDBC error

От
Дата:
> so if your driver is older than that, it may be the problem.
I use the JDBC  drive in package : postgresql-jdbc-7.4.1-1PGDG.i386.rpm.
And I user md5 in pg_hba.conf.
I think my default encoding is EUC-JP.

Do you think if I update my JDBC Driver , the error will go away?
This problem is so difficult to me. (-_-)b

>
> What version of the driver are you using? I see this in the CVS logs:
>
> > ----------------------------
> > revision 1.31
> > date: 2004/02/10 01:56:46;  author: jurka;  state: Exp;  lines: +14 -6
> > Don't try to turn the random bytes from a md5 salt into a String
> > because it may not be a valid String depending on the encoding.
> >
> > Per report from Nadeem Bitar.
> > ----------------------------
>
> so if your driver is older than that, it may be the problem.
>
> Failing that, are you using crypt-based authentication? ("crypt" in the
> appropriate access line in pg_hba.conf). From a quick glance at the code
> it looks like the crypt salt suffers from the same problem as md5 used
> to -- it tries to turn a couple of bytes into a String using the default
> encoding, which will not work reliably. As a temporary workaround, try
> changing pg_hba.conf to use "md5" instead of "crypt".
>
> If you use a different default encoding such as ISO-8859-1 (IIRC you can
> do this by setting the file.encoding system property, i.e.
> -Dfile.encoding=ISO-8859-1) does the problem go away?
>
> > ----------------err----------------------
> > DBAccess.getConnection(): Something unusual has occured to cause the
driver
> > to fail. Please report this exception: Exception:
> > java.lang.IllegalArgumentException
> > Stack Trace:
> >
> > java.lang.IllegalArgumentException
> >  at java.nio.Buffer.position(Buffer.java:218)
> >  at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:575)
> >  at java.lang.StringCoding$CharsetSD.decode(StringCoding.java:186)
> >  at java.lang.StringCoding.decode(StringCoding.java:224)
> >  at java.lang.StringCoding.decode(StringCoding.java:230)
> >  at java.lang.String.<init>(String.java:371)
> >  at
> >
org.postgresql.jdbc1.AbstractJdbc1Connection.openConnectionV2(AbstractJdbc1C
> > onnection.java:634)
>
> -O
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
>       joining column's datatypes do not match


Re: About a JDBC error

От
Oliver Jowett
Дата:
zhang-x@cnt.mxy.nes.nec.co.jp wrote:
>>so if your driver is older than that, it may be the problem.
>
> I use the JDBC  drive in package : postgresql-jdbc-7.4.1-1PGDG.i386.rpm.
> And I user md5 in pg_hba.conf.
> I think my default encoding is EUC-JP.
>
> Do you think if I update my JDBC Driver , the error will go away?
> This problem is so difficult to me. (-_-)b

An updated driver should fix it (build 213 from jdbc.postgresql.org
should be fine). CVS says that 7.4.1 used revision 1.27.2.1 which a)
matches the stacktrace line numbers and b) had the MD5 encoding bug.

-O