Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 32700 invoked from network); 24 Jan 2008 19:42:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 24 Jan 2008 19:42:48 -0000 Received: (qmail 89818 invoked by uid 500); 24 Jan 2008 19:42:36 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 89811 invoked by uid 500); 24 Jan 2008 19:42:36 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 89799 invoked by uid 99); 24 Jan 2008 19:42:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Jan 2008 11:42:36 -0800 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jeffgbutler@gmail.com designates 64.233.178.241 as permitted sender) Received: from [64.233.178.241] (HELO hs-out-2122.google.com) (64.233.178.241) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Jan 2008 19:42:09 +0000 Received: by hs-out-2122.google.com with SMTP id l65so344150hsc.0 for ; Thu, 24 Jan 2008 11:42:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=DT4On/Mcr2Z7EGuBZRN5nQCoZMU+u1p7L89n5bNa/aw=; b=atnVZd3oixoXaymL5iS5hyxbTEWoqvVG8lisDD1S3nXjaVqwMiA/PFAtGdlAxWCrNBs7Q96WlK5Kj4Z0D6QkfsY3acx6fBzxD4xr3+raCndl2Y9ORaIo9nx+brqmMKz48pKZgYpyL2sS/iBzebmxZkQHDHSurdSHJa610gKD6sc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=czXp1NvqdovYg3P1weA1XjLjOqGtmDcnqJ96V7wmJj5q3MMGYgRnVgs1NKho/XwElYaEnfJiM7m6ZzmotMQutBQmeds/2zrZ0WECNN6A2uay5vBrRrAccmm/iyws508Fh3DVz+2su5v43TUfKRSh11tQX5hwdrpKnTLWUUO/ddg= Received: by 10.114.25.3 with SMTP id 3mr1251289way.22.1201203733736; Thu, 24 Jan 2008 11:42:13 -0800 (PST) Received: by 10.114.74.9 with HTTP; Thu, 24 Jan 2008 11:42:13 -0800 (PST) Message-ID: Date: Thu, 24 Jan 2008 13:42:13 -0600 From: "Jeff Butler" To: user-java@ibatis.apache.org Subject: Re: How get DB2Connection object from SqlMapClient? In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_38244_20532196.1201203733715" References: X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_38244_20532196.1201203733715 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline I see. Then you'll need to do the "isProxy" method and check for SimplePooledConnection as the invocation handler. Then you can call the getRealConnection() method - which may return a further proxied object if logging is enabled. Proxy upon proxy - it can get complex to unwind these things. I have to wonder - is this really necessary? You can probably set the value you mentioned as a driver property and not have to write all this untangling code. Jeff Butler On Jan 24, 2008 12:33 PM, Hugh Ross wrote: > In my debugger, it looks like my Proxy is > actually SimpleDataSource-related, not logging. And, SimpleDataSource seems > to have a method to unrwrapConnection(). Still digging... > > > On 1/24/08, Jeff Butler wrote: > > > > I just checked SVN and that method was indeed added in 2.3. I'll add > > that information to the WIKI page. > > > > There's no other way to the underlying Connection object unless you > > disable logging in all circumstances, or you write some custom reflection > > code that gives you access to the private field. Upgrading to 2.3 is > > much easier (I would say that 2.3 is quite stable - it's been out over a > > year). > > > > Jeff Butler > > > > > > On Jan 24, 2008 11:56 AM, Hugh Ross wrote: > > > > > > > > Thanks, Jeff. I'm not finding a getConnection method in the > > > ConnectionLogProxy class. Is that because I'm using iBATIS 2.2.0? If > > > so, is there another way to get the underlying Connection object? > > > > > > > > > On 1/24/08, Jeff Butler wrote: > > > > > > > > This comes up a lot! I just added a WIKI page describing the > > > > process: > > > > > > > > http://opensource.atlassian.com/confluence/oss/pages/viewpage.action?pageId=15597591 > > > > > > > > > > > > Jeff Butler > > > > > > > > > > > > > > > > On Jan 24, 2008 10:03 AM, Hugh Ross wrote: > > > > > > > > > Can anyone provide some sample code for this? > > > > > > > > > > I tried, but seemed to be blocked by $proxy objects or odd looking > > > > > com.ibm.db2.jcc.b.b objects... > > > > > > > > > > For example, this did not work for me: > > > > > > > > > > java.sql.Connection conn = > > > > > sqlMapClient.getCurrentConnection(); > > > > > > > > > > if (conn instanceof com.ibm.db2.jcc.DB2Connection ) > > > > > { > > > > > com.ibm.db2.jcc.DB2Connection db2conn = ( > > > > > com.ibm.db2.jcc.DB2Connection)conn; > > > > > db2conn.setDB2ClientApplicationInformation > > > > > ("SomethingUsefulHere"); > > > > > } > > > > > > > > > > I also tried getting the DataSource 1st. > > > > > > > > > > Thanks! > > > > > > > > > > > > > > > > > > > > > > > > ------=_Part_38244_20532196.1201203733715 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
I see.  Then you'll need to do the "isProxy" method and check for SimplePooledConnection as the invocation handler.  Then you can call the getRealConnection() method - which may return a further proxied object if logging is enabled.  Proxy upon proxy - it can get complex to unwind these things.
 
I have to wonder - is this really necessary?  You can probably set the value you mentioned as a driver property and not have to write all this untangling code.
 
Jeff Butler
 


 
On Jan 24, 2008 12:33 PM, Hugh Ross <hh4ross@gmail.com> wrote:
In my debugger, it looks like my Proxy is actually SimpleDataSource-related, not logging.  And, SimpleDataSource seems to have a method to unrwrapConnection().  Still digging...


On 1/24/08, Jeff Butler <jeffgbutler@gmail.com> wrote:
I just checked SVN and that method was indeed added in 2.3.  I'll add that information to the WIKI page.
 
There's no other way to the underlying Connection object unless you disable logging in all circumstances, or you write some custom reflection code that gives you access to the private field.  Upgrading to 2.3 is much easier (I would say that 2.3 is quite stable - it's been out over a year).
 
Jeff Butler

 
On Jan 24, 2008 11:56 AM, Hugh Ross <hh4ross@gmail.com> wrote:
 
Thanks, Jeff.  I'm not finding a getConnection method in the ConnectionLogProxy class.  Is that because I'm using iBATIS 2.2.0?  If so, is there another way to get the underlying Connection object?

 
On 1/24/08, Jeff Butler <jeffgbutler@gmail.com > wrote:
This comes up a lot!  I just added a WIKI page describing the process:
 
 
Jeff Butler


 
On Jan 24, 2008 10:03 AM, Hugh Ross <hh4ross@gmail.com> wrote:

Can anyone provide some sample code for this? 

I tried, but seemed to be blocked by $proxy objects or odd looking com.ibm.db2.jcc.b.b objects...

For example, this did not work for me:

        java.sql.Connection conn = sqlMapClient.getCurrentConnection();
       
        if (conn instanceof com.ibm.db2.jcc.DB2Connection )
        {
            com.ibm.db2.jcc.DB2Connection db2conn = (com.ibm.db2.jcc.DB2Connection)conn;
            db2conn.setDB2ClientApplicationInformation("SomethingUsefulHere");
        }

I also tried getting the DataSource 1st.

Thanks!



 



------=_Part_38244_20532196.1201203733715--