Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id D027A1337990 for ; Fri, 15 Oct 2010 22:08:52 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 57648-07 for ; Sat, 16 Oct 2010 01:08:46 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail63.csoft.net (mail63.csoft.net [205.205.214.4]) by mail.postgresql.org (Postfix) with ESMTP id 5FAED1336DB6 for ; Fri, 15 Oct 2010 22:08:45 -0300 (ADT) Received: from mail63.csoft.net (localhost [127.0.0.1]) by mail63.csoft.net (Postfix) with ESMTP id 6065A28434; Fri, 15 Oct 2010 21:08:45 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=csoft.net; h=date:from:to :cc:subject:in-reply-to:message-id:references:mime-version :content-type; s=sel1; bh=R4+vaT1r21Vo5/ISFvitPExNzZ0=; b=3BD7+v Eg13ZMwlI8hyxdW+hzyBZdYyP7lFCAb7FxJ1SFKu/ByDApGTmiBx7vmXf0+FW7CA /V7MmxxOBWKbNL0Lx2oH+vSkxF0fZAZ1w+KUUSe0mhfuqmC/X1wCAxwXbeRBTuae IuU8tZTAAXl9eGIvqEfsNbvvbziQ/wPOGkDm8= Received: from leary.csoft.net (leary.csoft.net [205.205.214.5]) by mail63.csoft.net (Postfix) with ESMTP id 530292842A; Fri, 15 Oct 2010 21:08:45 -0400 (EDT) Received: by leary.csoft.net (Postfix, from userid 1112) id 23E04A3C8; Fri, 15 Oct 2010 21:08:45 -0400 (EDT) Date: Fri, 15 Oct 2010 21:08:44 -0400 (EDT) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Yaocl cc: pgsql-jdbc@postgresql.org Subject: Re: Re: call XAConnection.commit() when autoCommit=true throw InvocationTargetException not SQLException. In-Reply-To: Message-ID: References: User-Agent: Alpine 2.00 (BSO 1167 2008-08-23) MIME-Version: 1.0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: Content-Type: TEXT/PLAIN; charset=UTF-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE X-Archive-Number: 201010/116 X-Sequence-Number: 21084 Thanks, I've applied this patch to CVS. Kris Jurka On Thu, 14 Oct 2010, Yaocl wrote: > Hi > > This is a quick patch to current head. > > Regards, > Yao > > On Thu, Oct 14, 2010 at 6:24 PM, Yaocl wrote: >> Hi >> >> According to the javadoc call commit() on autoCommit=3Dtrue connection >> will throw a SQLException. But a PGXAConnection >> thrown a=C2=A0InvocationTargetException. >> >> Because the following code, It use reflection internally. >> method.invoke() will throw InvocationTargetException when underlying >> method throw a Exception. >> >> =C2=A0/* >> =C2=A0=C2=A0 =C2=A0 * A java.sql.Connection proxy class to forbid calls = to transaction >> =C2=A0=C2=A0 =C2=A0 * control methods while the connection is used for a= n XA transaction. >> =C2=A0=C2=A0 =C2=A0 */ >> =C2=A0=C2=A0 =C2=A0private class ConnectionHandler implements Invocation= Handler >> =C2=A0=C2=A0 =C2=A0{ >> private Connection con; >> public ConnectionHandler(Connection con) >> { >> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0this.con =3D con; >> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0} >> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0public Object invoke(Object proxy, Meth= od method, Object[] args) >> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0throws Throwable >> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0{ >> =C2=A0 =C2=A0if (state !=3D STATE_IDLE) >> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{ >> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0String meth= odName =3D method.getName(); >> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (methodN= ame.equals("commit") || >> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0methodName.equals("rollback") || >> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0methodName.equals("setSavePoint") || >> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0(methodName.equals("setAutoCommit") && ((Boolean) >> args[0]).booleanValue())) >> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{ >> =C2=A0 =C2=A0throw new PSQLException(GT.tr("Transaction control methods >> setAutoCommit(true), commit, rollback and setSavePoint not allowed >> while an XA transaction is active."), >> =C2=A0 =C2=A0PSQLState.OBJECT_NOT_IN_STATE); >> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0} >> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0} >> =C2=A0 =C2=A0return method.invoke(con, args); >> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0} >> =C2=A0=C2=A0 =C2=A0} >> >> Regards, >> Yao >> >=