Skip site navigation (1) Skip section navigation (2)

Re: Very strange Error in Updates

From: "Dario V(dot) Fassi" <software(at)sistemat(dot)com(dot)ar>
To: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>,Oliver Jowett <oliver(at)opencloud(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Very strange Error in Updates
Date: 2004-07-16 05:27:04
Message-ID: 40F76728.8080408@sistemat.com.ar (view raw, whole thread or download thread mbox)
Thread:
Lists: pgsql-hackerspgsql-jdbc
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.
>



In response to

pgsql-hackers by date

Next:From: listsDate: 2004-07-16 05:32:01
Subject: XLogWrite: write request 0/53A4000 is past end of log 0/53A4000
Previous:From: listsDate: 2004-07-16 05:21:44
Subject: XLogWrite: write request 0/53A4000 is past end of log 0/53A4000

pgsql-jdbc by date

Next:From: Dario V. FassiDate: 2004-07-16 05:49:27
Subject: Re: Very strange Error in Updates - At last resolved !
Previous:From: Oliver JowettDate: 2004-07-16 03:16:59
Subject: Re: Adding JDK1.5 removing 1.1 support.

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group