Thread: JDBC driver reports a protocol error for a CVS HEAD server

JDBC driver reports a protocol error for a CVS HEAD server

From
"Ned T. Crigler"
Date:
The JDBC driver does not connect successfully to a CVS HEAD server
(updated as of today) when using a database set to UTF8 encoding;
enabling the debug messages in the driver shows that it is sending
client_encoding=UNICODE in the startup packet, but the server is
reporting client_encoding=UTF8 back to the driver, causing the driver
to complain:

15:25:23.136 (1) PostgreSQL 8.2devel JDBC3 with SSL (build 503)
15:25:23.151 (1) Trying to establish a protocol version 3 connection to localhost:5432
15:25:23.171 (1)  FE=> StartupPacket(user=crigler, database=wave, client_encoding=UNICODE, DateStyle=ISO)
15:25:23.175 (1)  <=BE AuthenticationOk
15:25:23.202 (1)  <=BE ParameterStatus(client_encoding = UTF8)
org.postgresql.util.PSQLException: Protocol error.  Session setup failed.
    at org.postgresql.core.v3.ConnectionFactoryImpl.readStartupMessages(ConnectionFactoryImpl.java:470)
    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:98)
    at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
    at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:125)
    at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
    at org.postgresql.jdbc3.Jdbc3Connection.<init>(Jdbc3Connection.java:24)
    at org.postgresql.Driver.makeConnection(Driver.java:382)
    at org.postgresql.Driver.connect(Driver.java:260)
    at java.sql.DriverManager.getConnection(DriverManager.java:525)
    at java.sql.DriverManager.getConnection(DriverManager.java:171)
    at DBConn.<init>(DBConn.java:24)
    at g.main(g.java:11)
SQLException: SQLState(08001)
getConnection failed: org.postgresql.util.PSQLException: Protocol error.  Session setup failed.
SQL Error: Database Open Failure
org.postgresql.util.PSQLException: Protocol error.  Session setup failed.

--
Ned T. Crigler

Re: JDBC driver reports a protocol error for a CVS HEAD server

From
Kris Jurka
Date:

On Tue, 24 Apr 2007, Ned T. Crigler wrote:

> The JDBC driver does not connect successfully to a CVS HEAD server
> (updated as of today) when using a database set to UTF8 encoding;
> enabling the debug messages in the driver shows that it is sending
> client_encoding=UNICODE in the startup packet, but the server is
> reporting client_encoding=UTF8 back to the driver, causing the driver
> to complain:

Indeed, referring to -hackers as this is a recent backend change.  The
backend is reporting the database encoding as the client encoding.  When a
connection is created with a startup packet sending client_encoding =
UNICODE the server responds with a ParameterStatus message of
client_encoding = server encoding.  So something has gone wrong here.
It's not just a UNICODE/UTF-8 problem as I see the server responding with
LATIN1 with a LATIN1 database.

Kris Jurka


Kris Jurka <books@ejurka.com> writes:
> On Tue, 24 Apr 2007, Ned T. Crigler wrote:
>> The JDBC driver does not connect successfully to a CVS HEAD server
>> (updated as of today) when using a database set to UTF8 encoding;

> Indeed, referring to -hackers as this is a recent backend change.  The
> backend is reporting the database encoding as the client encoding.

Confirmed here: psql has stopped obeying the PGCLIENTENCODING
environment variable.  Can't help suspecting that the recent
GUC-parameter-rollback change broke it.  (That has got to be one
of the most snakebit projects we've had ... apparently the latest
try needs reverted, again.)

            regards, tom lane