Re: jdbc-4.1 v42.0.0 - set client_encoding

From: Jorge Solórzano <jorsol(at)gmail(dot)com>
To: Rob Resendez <resendez(dot)java(at)gmail(dot)com>
Cc: List <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: jdbc-4.1 v42.0.0 - set client_encoding
Date: 2017-03-16 22:02:52
Message-ID: CA+cVU8O4hwr4Z=TcoxsoWqGXMrg2WNORV3JT7Cg_1v86Hxo4wg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Just to quote the PostgreSQL docs
<https://www.postgresql.org/docs/9.6/static/multibyte.html#MULTIBYTE-CHARSET-SUPPORTED>
:

The SQL_ASCII setting behaves considerably differently from the other
> settings. When the server character set is SQL_ASCII, the server
> interprets byte values 0-127 according to the ASCII standard, while byte
> values 128-255 are taken as uninterpreted characters. No encoding
> conversion will be done when the setting is SQL_ASCII. Thus, this setting
> is not so much a declaration that a specific encoding is in use, as a
> declaration of ignorance about the encoding. In most cases, if you are
> working with any non-ASCII data, it is unwise to use the SQL_ASCII
> setting because PostgreSQL will be unable to help you by converting or
> validating non-ASCII characters.

​So the path to force the client_encoding might not be wise​.

Jorge Solórzano

On Thu, Mar 16, 2017 at 2:21 PM, Rob Resendez <resendez(dot)java(at)gmail(dot)com>
wrote:

> jdbc-4.1 v42.0.0
>
> Our database enoding is "SQL_ASCII". JDBC's client_encoding is "UTF-8"
> We're making the leap from pg9.2 to 9.6... and existing code has started
> throwing exceptions:
>
> "invalid byte sequence for encoding "UTF8"..."
>
> Per this thread:
> https://www.postgresql.org/message-id/55CA237A.4080300@nqadmin.com
>
> "9.4 is intentionally less lax about that than prior versions" (regarding
> character data not supported by the client encoding)
>
> We've decided to force the JDBC client_encoding to "SQL_ASCII". Per the
> docs, "allowEncodingChanges" will allow "SET client_encoding..." execution;
> However, I'm wondering if there is a way to force the connection to use a
> particular encoding to begin with?
>
> I've tried "props.setProperty('client_encoding', ...)" without success.
>
> Thanks
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2017-03-19 20:26:22 [pgjdbc/pgjdbc] 95a3f4: fix callproc escape documentation the specificatio...
Previous Message Rob Resendez 2017-03-16 20:21:07 jdbc-4.1 v42.0.0 - set client_encoding