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

Re: JDBC causing the connection to close after executing a COPY command

From: Altaf Malik <mmalik_altaf(at)yahoo(dot)com>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: Dave Cramer <pg(at)fastcrypt(dot)com>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: JDBC causing the connection to close after executing a COPY command
Date: 2007-12-13 19:09:49
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
I debugged little more and found that this is not because of incomplete copy support. When a response to any of the copy operations is received, JDBC reads next few bytes to ignore the response. But unfortunately driver reads extra four bytes which is the RFQ message so the RFQ message gets corrupted and IOException is thrown considering it as an unknown packet.

I am attaching a patch that fixes this issue and driver works smoothly even after giving the error on copy response.

Altaf Malik

Kris Jurka <books(at)ejurka(dot)com> wrote: 

On Thu, 13 Dec 2007, Altaf Malik wrote:

> Also if i enable logging in JDBC, and only execute the COPY statement, 
> log shows that FrontEnd sent a Terminate message.

What's happening is that after receiving the server's message that it 
wants to do a COPY, the driver doesn't understand the protocol and dies 
with an " Unexpected packet type: " error.  Once this 
happens the driver can't do anything but close the connection.  As part of 
the connection closing process it issues a Terminate message to the 
server, in case it's still listening and the protocol is in a good enough 
state that the server might receive it.  The driver is not explicitly 
terminating the connection upon receiving a copy request, that's just what 
happens when it gets confused.

Kris Jurka

Never miss a thing.   Make Yahoo your homepage.

Attachment: pg_copy.diff
Description: text/x-patch (973 bytes)

In response to


pgsql-jdbc by date

Next:From: Tom DuffeyDate: 2007-12-13 21:15:19
Subject: Slow query after upgrades
Previous:From: dmpDate: 2007-12-13 18:11:46
Subject: Re: how to set a PreparedStatement column of XML type in 8.3?

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