X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E14DDD1B170 for ; Fri, 16 Jul 2004 02:17:58 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 44278-01 for ; Fri, 16 Jul 2004 05:17:56 +0000 (GMT) Received: from mail.svhost.com.ar (mail.svhost.com.ar [200.80.239.22]) by svr1.postgresql.org (Postfix) with ESMTP id 5A1C4D1B181 for ; Fri, 16 Jul 2004 02:17:53 -0300 (ADT) Received: from sistemat.com.ar (devel.sistemat.com.ar [192.168.1.40]) by mail.svhost.com.ar (Postfix) with ESMTP id BE03D23A03; Fri, 16 Jul 2004 02:16:15 -0300 (ART) Message-ID: <40F76728.8080408@sistemat.com.ar> Date: Fri, 16 Jul 2004 02:27:04 -0300 From: "Dario V. Fassi" Organization: SISTEMATICA ingenieria de software srl User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: es, es-ar, en-us, en MIME-Version: 1.0 To: "pgsql-jdbc@postgresql.org" , Oliver Jowett , Tom Lane Subject: Re: Very strange Error in Updates References: <40F6172D.10301@sistemat.com.ar> <40F618DF.7070609@sistemat.com.ar> In-Reply-To: <40F618DF.7070609@sistemat.com.ar> Content-Type: multipart/alternative; boundary="------------010503060009090505010606" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.0 tagged_above=0.0 required=5.0 tests=HTML_20_30, HTML_MESSAGE, HTML_TITLE_EMPTY X-Spam-Level: * X-Archive-Number: 200407/200 X-Sequence-Number: 10584 This is a multi-part message in MIME format. --------------010503060009090505010606 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Now as suggested we are working with a UNICODE database. With lastest dev Jdbc driver , don't work. With and older mammoth Jdbc driver they work but the original problem return. A java string of 30 chars can't be updated over a varchar(30) field, even with a UNICODE db. Something in the middle has a wrong count of chars even if a database encoding is Unicode. Server or Interface ? Dario. Dario V. Fassi wrote: > Worst cases: > > The receiving field is a Varchar(30) . > Sample data : > > CALLE=[ENFERMERA CLEMON. B- ALTO ALBR] len=30 : Is Updated Ok. > CALLE=[ENFERMERA CLEMON. Bº ALTO ALBR] len=30 : Is NOT Updated > CALLE=[ENFERMERA CLEMON. Bº ALTO ALB] len=29 : Is Updated Ok. > > Dario V. Fassi wrote: > >> I found a very strange error/behavior in a PreparedStatement for a >> simple SQL Update over a VARCHAR field. >> The code is like: >> >> Statement stmt = con.createStatement(); >> PreparedStatement pstIns = con.prepareStatement("update userid.t >> set calle = ? "); ResultSet rs = stmt.executeQuery( "select >> calle from userid.t2" ); >> while ( rs.next() ) { >> pstIns.clearParameters(); >> String x = rs.getString("CALLE"); >> pstIns.setString(1, x ); >> int nrows = pstIns.executeUpdate(); >> System.out.println( "Filas afectadas "+ nrows ); >> } >> >> When the parameter fill the full-length of receiving field and has >> any non common character, the update throw a exception like: >> >> java.sql.SQLException: ERROR: value too long for type character >> varying(30) >> at >> org.postgresql.core.v2.QueryExecutorImpl.receiveErrorMessage(QueryExecutorImpl.java:420) >> >> at >> org.postgresql.core.v2.QueryExecutorImpl.processResults(QueryExecutorImpl.java:345) >> >> at >> org.postgresql.core.v2.QueryExecutorImpl.execute(QueryExecutorImpl.java:251) >> >> at >> org.postgresql.core.v2.QueryExecutorImpl.execute(QueryExecutorImpl.java:159) >> >> at >> org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:342) >> >> at >> org.postgresql.jdbc1.AbstractJdbc1Statement.executeWithFlags(AbstractJdbc1Statement.java:290) >> >> at >> org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdbc1Statement.java:245) >> >> at >> com.sistemat.app.rsmaster.reloadable.RepImportar.PrDw_Cuentas(RepImportar.java:2471) >> >> at >> com.sistemat.app.rsmaster.reloadable.RepImportar.Importar(RepImportar.java:260) >> >> at >> com.sistemat.app.rsmaster.reloadable.RepMasterImpl.Ciclo_Replicacion(RepMasterImpl.java:955) >> >> at >> com.sistemat.app.rsmaster.reloadable.RepMasterImpl.runWorker(RepMasterImpl.java:748) >> >> at >> com.sistemat.app.rsmaster.reloadable.RepMasterImpl.run(RepMasterImpl.java:427) >> >> at java.lang.Thread.run(Unknown Source) >> >> This field/value produce the Exception: CALLE=[ENFERMERA CLEMON. B§ >> ALTO ALBR] >> >> If this field is changed to: CALLE=[ENFERMERA >> CLEMON. B# ALTO ALBR] >> then the update is performed without >> any problem. >> >> Although the first value can be Inserted with a prepared statement >> without problems. >> >> A have no explanation to this case , and any help will be appreciated. >> >> Dario Fassi. > --------------010503060009090505010606 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit Now as suggested we are working with a UNICODE database.
With lastest dev Jdbc driver , don't work.
With and older mammoth Jdbc driver they work but the original problem return.

A java string of 30 chars can't be updated over a varchar(30) field, even with a UNICODE db.

Something in the middle has a wrong count of chars even if a database encoding is Unicode. 
Server or Interface ?

Dario.

Dario V. Fassi wrote:
Worst cases:

The receiving field is a Varchar(30) .
Sample data :

CALLE=[ENFERMERA CLEMON. B- ALTO ALBR]  len=30    : Is Updated Ok.
CALLE=[ENFERMERA CLEMON. Bº ALTO ALBR]  len=30    : Is NOT Updated
CALLE=[ENFERMERA CLEMON. Bº ALTO ALB]  len=29    : Is Updated Ok.

Dario V. Fassi wrote:
I found a very strange error/behavior in a PreparedStatement  for a simple SQL Update over a VARCHAR field.
The code is like:

   Statement stmt = con.createStatement();
   PreparedStatement pstIns = con.prepareStatement("update userid.t set calle = ? ");         ResultSet rs = stmt.executeQuery( "select calle from userid.t2" );
   while ( rs.next() ) {
               pstIns.clearParameters();
               String x = rs.getString("CALLE");
               pstIns.setString(1, x );
               int nrows = pstIns.executeUpdate();
               System.out.println( "Filas afectadas "+ nrows );
    }
         
When the parameter fill the full-length of  receiving field and has any non common character, the update throw a exception like:

java.sql.SQLException: ERROR:  value too long for type character varying(30)
   at org.postgresql.core.v2.QueryExecutorImpl.receiveErrorMessage(QueryExecutorImpl.java:420)
   at org.postgresql.core.v2.QueryExecutorImpl.processResults(QueryExecutorImpl.java:345)
   at org.postgresql.core.v2.QueryExecutorImpl.execute(QueryExecutorImpl.java:251)
   at org.postgresql.core.v2.QueryExecutorImpl.execute(QueryExecutorImpl.java:159)
   at org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:342)
   at org.postgresql.jdbc1.AbstractJdbc1Statement.executeWithFlags(AbstractJdbc1Statement.java:290)
   at org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdbc1Statement.java:245)
   at com.sistemat.app.rsmaster.reloadable.RepImportar.PrDw_Cuentas(RepImportar.java:2471)
   at com.sistemat.app.rsmaster.reloadable.RepImportar.Importar(RepImportar.java:260)
   at com.sistemat.app.rsmaster.reloadable.RepMasterImpl.Ciclo_Replicacion(RepMasterImpl.java:955)
   at com.sistemat.app.rsmaster.reloadable.RepMasterImpl.runWorker(RepMasterImpl.java:748)
   at com.sistemat.app.rsmaster.reloadable.RepMasterImpl.run(RepMasterImpl.java:427)
   at java.lang.Thread.run(Unknown Source)

This field/value produce the Exception:   CALLE=[ENFERMERA CLEMON. B§ ALTO ALBR]

If this field is changed to:                        CALLE=[ENFERMERA CLEMON. B# ALTO ALBR]
then  the update is performed without
any problem.

Although the first value can be Inserted  with a prepared statement  without problems.

A have no explanation to this case , and any help will be appreciated.

Dario Fassi.



--------------010503060009090505010606--