Re: UTF encoding error

From: Fernando Nasser <fnasser(at)redhat(dot)com>
To: Felipe Schnack <felipes(at)ritterdosreis(dot)br>
Cc: pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: UTF encoding error
Date: 2002-12-04 17:53:32
Message-ID: 3DEE411C.6030309@redhat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-jdbc

Oi Felipe,

The code in the driver is straight forward so the only way you can get one of
those is that the string sent by the backend is encoded wrong. (I guess we will
have to catch this error and give a better message anyway).

As of 7.3, the backend does the conversion between your encoding (databse
encoding) and UNICODE (client encoding set with "set client_encoding =
'UNICODE';") and sends everything as UTF8 to the driver. If the stream of bytes
send has something wrong and says that there is a 3 byte sequence and only two
are there we could get this exception. But this means that the conversion was
made wrong in the backend.

Have you initialized your cluster with -E ? Isn't it possible that you did not
tell the backend that it is supposed to work with Brazilian Portuguese and
loaded some encoded data there using some binary form?

Cheers,
Fernando

Felipe Schnack wrote:> I'm getting this error, I'm pretty sure it's a driver
error, but can't
> imagine why... I'm just fetching string (in br-pt language)
>
> java.lang.ArrayIndexOutOfBoundsException: 15
> at org.postgresql.core.Encoding.decodeUTF8(Encoding.java:254)
> at org.postgresql.core.Encoding.decode(Encoding.java:165)
> at org.postgresql.core.Encoding.decode(Encoding.java:181)
> at
> org.postgresql.jdbc1.AbstractJdbc1ResultSet.getString(AbstractJdbc1ResultSet.java:97)
> at
> org.apache.commons.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java)
> at com.w2.infra.db.CtlDatabase.getField(CtlDatabase.java:60)
> at com.w2.infra.mvc.CtlModel.importResultRow(CtlModel.java:48)
> at com.w2.infra.db.DbVector.getLinkedList(DbVector.java:310)
> at com.w2.infra.db.CachedVector.&lt;init&gt;(CachedVector.java:48)
> at com.w2.infra.tags.CtlInvokerTag.doEnd(CtlInvokerTag.java:87)
> at com.w2.infra.tags.BodyTagLib.doEndTag(BodyTagLib.java:86)
> at
> org.apache.jsp.questionariocopia_jsp._jspx_meth_w2_invoker_0(questionariocopia_jsp.java:158)
> at
> org.apache.jsp.questionariocopia_jsp._jspService(questionariocopia_jsp.java:64)
> at org.apache.jasper.runtime.HttpJspBase.service(Unknown Source)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java)
> at org.apache.jasper.servlet.JspServletWrapper.service(Unknown Source)
> at org.apache.jasper.servlet.JspServlet.serviceJspFile(Unknown Source)
> at org.apache.jasper.servlet.JspServlet.service(Unknown Source)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Unknown
> Source)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(Unknown
> Source)
> at
> com.w2.infra.servlets.ErrorPageFilter.doFilter(ErrorPageFilter.java:25)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Unknown
> Source)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(Unknown
> Source)
> at org.apache.catalina.core.StandardWrapperValve.invoke(Unknown Source)
> at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(Unknown Source)
> at org.apache.catalina.core.StandardPipeline.invoke(Unknown Source)
> at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
> at org.apache.catalina.core.StandardContextValve.invoke(Unknown Source)
> at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(Unknown Source)
> at org.apache.catalina.core.StandardPipeline.invoke(Unknown Source)
> at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
> at org.apache.catalina.core.StandardContext.invoke(Unknown Source)
> at org.apache.catalina.core.StandardHostValve.invoke(Unknown Source)
> at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(Unknown Source)
> at org.apache.catalina.valves.ErrorDispatcherValve.invoke(Unknown
> Source)
> at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(Unknown Source)
> at org.apache.catalina.valves.ErrorReportValve.invoke(Unknown Source)
> at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(Unknown Source)
> at org.apache.catalina.core.StandardPipeline.invoke(Unknown Source)
> at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
> at org.apache.catalina.core.StandardEngineValve.invoke(Unknown Source)
> at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(Unknown Source)
> at org.apache.catalina.core.StandardPipeline.invoke(Unknown Source)
> at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
> at
> org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
> at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
> at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:380)
> at
> org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
> at
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533)
> at java.lang.Thread.run(Thread.java:536)
>
>

--
Fernando Nasser
Red Hat - Toronto E-Mail: fnasser(at)redhat(dot)com
2323 Yonge Street, Suite #300
Toronto, Ontario M4P 2C9

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2002-12-04 17:57:05 Re: [GENERAL] PostgreSQL Global Development Group Announces
Previous Message Bruce Momjian 2002-12-04 17:41:55 Re: Anyone working on OLAP stuff?

Browse pgsql-jdbc by date

  From Date Subject
Next Message Felipe Schnack 2002-12-04 17:58:41 Re: UTF encoding error
Previous Message Felipe Schnack 2002-12-04 13:10:28 UTF encoding error