charset property is not working - Mailing list pgsql-jdbc

From Katalina Marcos
Subject charset property is not working
Date
Msg-id 000a01c43904$063beee0$770210ac@kmarcos
Whole thread Raw
Responses Re: charset property is not working
List pgsql-jdbc

Hi all!

 

Please help me!

 

I’m using postgresql  7.3.2 (datasource) and jboss…

 

When I try to query a table , I get  this error:

 

Invalid character data was found.  This is most likely caused by stored data containing characters that are invalid f

or the character set the database was created in.  The most common example of this is storing 8bit data in a SQL_ASCII database.

 

That is because in a row I have the character ¥… In the postgresql’s log I get…

 

LOG:  query: select * from t_migracion_historico where lower(tps_migrhist_basedato) = 'repuestos' and lower(ts_migrhist_tablorig) = 't_moneda' and (upper(ts_migrhist_procesado)='N' or ts_migrhist_procesado is null)

LOG:  query: select * from t_migracion_historico;

LOG:  query: set datestyle to 'ISO'; select version(), case when pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else getdatabaseencoding() end;

LOG:  query: ÿþs

ERROR:  parser: parse error at or near "ÿþs" at character 1

FATAL:  Socket command type e unknown

 

So, I try to set the connection property in the datasource descriptor:

 

<connection-property name="charSet">UNICODE</connection-property>

 

Because I set client_encoding to UNICODE in postgresql.config.

 

 

But when I try to run the application again, it throws

 

Could not create connection; - nested throwable: (Something unusual has occured to cause the driver to fail. Please report this exception: Exception: java.sql.SQLException:

Stack Trace:

 

java.sql.SQLException:

       at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:131)

       at org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:482)

       at org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:461)

       at org.postgresql.jdbc1.AbstractJdbc1Connection.openConnection(AbstractJdbc1Connection.java:376)

       at org.postgresql.Driver.connect(Driver.java:122)

       at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:150)

       at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:477)

...

 

Could anybody help to me? What is the right way to do this query?

 

Thanks in advance!

Katalina

pgsql-jdbc by date:

Previous
From: Andrea Aime
Date:
Subject: Connection pooling, jdbc3 and encoding
Next
From: Kris Jurka
Date:
Subject: Re: [BUG?] Extreme dates