X-Original-To: pgsql-jdbc-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id EFBCE9FB1D4 for ; Thu, 14 Sep 2006 07:08:36 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 14553-03 for ; Thu, 14 Sep 2006 10:08:33 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by postgresql.org (Postfix) with ESMTP id 124AF9FA6B1 for ; Thu, 14 Sep 2006 07:08:32 -0300 (ADT) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1GNo8o-0001or-B3 for pgsql-jdbc@postgresql.org; Thu, 14 Sep 2006 12:08:18 +0200 Received: from 83.145.96.118 ([83.145.96.118]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 14 Sep 2006 12:08:18 +0200 Received: from Marc.Herbert by 83.145.96.118 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 14 Sep 2006 12:08:18 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-jdbc@postgresql.org From: Marc Herbert Subject: Re: about monitoring the input stream Date: Thu, 14 Sep 2006 12:08:09 +0200 Lines: 31 Message-ID: References: <200609131809.55435.acardona@ini.phys.ethz.ch> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 83.145.96.118 User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4 (Jumbo Shrimp, linux) Cancel-Lock: sha1:3XwkNEk/pnUQehJwNO5q/twrwMM= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.633 tagged_above=0 required=5 tests=FORGED_RCVD_HELO, RCVD_NUMERIC_HELO, SPF_HELO_PASS, SPF_PASS X-Spam-Level: * X-Archive-Number: 200609/53 X-Sequence-Number: 15771 Albert Cardona writes: > The idea is not to modify the driver one bit in benefit of uncontroversial > deployment of my application (TrakEM2 at > http://www.ini.unizh.ch/~acardona/trackem2.html ). If java was lisp I would > simply alter the register to replace the InputStream, but it isn't and/or I > don't know how to use reflection to that extent Thanks to its reflection API, java is actually lisp. Just a bit less convenient. This should do the trick: pg_input_field = PGStream.class.getDeclaredField("pg_input"); pg_input_field.setAccessible(true); InputStream orig_stream = (InputStream) pg_input_field.get(pg_stream_to_hack); InputStream counting_stream = new CountingInputStream(orig_stream); pg_input_field.set(pg_stream_to_hack, counting_stream); > (I don't know what would happen was I to replace the InputStream > using reflection once a connection has been created). As far as I understand the driver you _have to_ replace it after the connection has been created. Just avoid using it before replace.