Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id DFF092E0184 for ; Thu, 13 Dec 2007 11:37:16 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 92154-05 for ; Thu, 13 Dec 2007 11:37:12 -0400 (AST) Received: from beaver.fastcrypt.com (beaver.fastcrypt.com [64.7.141.17]) by postgresql.org (Postfix) with ESMTP id 70D332E017C for ; Thu, 13 Dec 2007 11:37:12 -0400 (AST) Received: from [192.168.1.14] (dcdsl.ebox.com [64.7.143.116]) by beaver.fastcrypt.com (Postfix) with ESMTP id 5395A15806E4; Thu, 13 Dec 2007 10:50:16 -0500 (EST) Cc: pgsql-jdbc@postgresql.org Message-Id: <33B38B63-7DB9-405B-A808-0152A5DB6295@fastcrypt.com> From: Dave Cramer To: Altaf Malik In-Reply-To: <669991.48395.qm@web39114.mail.mud.yahoo.com> Content-Type: multipart/alternative; boundary=Apple-Mail-36-209698597 Mime-Version: 1.0 (Apple Message framework v915) Subject: Re: JDBC causing the connection to close after executing a COPY command Date: Thu, 13 Dec 2007 10:37:10 -0500 References: <669991.48395.qm@web39114.mail.mud.yahoo.com> X-Mailer: Apple Mail (2.915) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/85 X-Sequence-Number: 17940 --Apple-Mail-36-209698597 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Altaf, On 13-Dec-07, at 10:24 AM, Altaf Malik wrote: > Hi, > JDBC is causing the connection to close on executing a simple COPY > query which the driver does not support. The code shows that driver > throws an exception however explicitly the connection is not closed. > Consider the following case. > > Class.forName("org.postgresql.Driver"); > Connection con = DriverManager.getConnection("jdbc:postgresql:// > localhost/postgres","altaf",""); > > Statement stmt = con.createStatement(); > stmt.execute("create table abc(a int4)"); > try{ > stmt.execute("COPY abc TO STDOUT WITH DELIMITER '|'"); > }catch(Exception e) { > e.printStackTrace(); > } > stmt.execute("Select * from abc"); > > > > Can anybody tell what's happening? > At what point can you determine the connection is closed ? Can you do con.createStatement after the exception ? Dave > Thanks, > Altaf Malik > EnterpriseDB > http://www.enterprisedb.com/ > > Looking for last minute shopping deals? Find them fast with Yahoo! > Search. --Apple-Mail-36-209698597 Content-Type: text/html; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Altaf,
On = 13-Dec-07, at 10:24 AM, Altaf Malik wrote:

Hi,
 JDBC is causing the connection to close on = executing a simple COPY query which the driver does not support. The = code shows that driver throws an exception however explicitly the = connection is not closed. Consider the following = case.
<code>
Class.forName("org.postgresql.Driver");
Connec= tion con =3D = DriverManager.getConnection("jdbc:postgresql://localhost/postgres","altaf"= ,"");

Statement stmt =3D = con.createStatement();
stmt.execute("create table abc(a = int4)");
try{
        = stmt.execute("COPY abc TO STDOUT WITH DELIMITER = '|'");
        }catch(Exception e) = {
            = e.printStackTrace();
        = }
        stmt.execute("Select * = from abc");

</code>

Can anybody tell what's = happening?

At what point can you determine the = connection is closed ? Can you do con.createStatement after the = exception ?

Dave
Thanks,
Altaf Malik
EnterpriseDB
http://www.enterprisedb.com/
=


Looking for last minute shopping deals? Find them fast with Yahoo! = Search.

= --Apple-Mail-36-209698597--