You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Hugh Ross <hh...@gmail.com> on 2008/01/24 17:03:36 UTC

How get DB2Connection object from SqlMapClient?

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!

Re: How get DB2Connection object from SqlMapClient?

Posted by Hugh Ross <hh...@gmail.com>.
Well, reporting might be the wrong term.  More like Accounting.  Long
story.  Deserves separate thread.  Not really changing driver config,
either.  Just "client" information, that gets passed to the database server
with the SQL.  DBAs can see it in Traces; gets recorded in (database)
accounting records (e.g., SMF, then MXG, Mainframe stuff), etc.  As I said,
long story.

Example -- say you have data access services like GetCustomerInfo,
SearchForProduct, SaveABunchOfData, etc.  Each one of which does perhaps
dozens of SQL calls.  Tools like MXG can be used to accumulate the data, and
then you can use it to track performance over time, among other things...

 I don't know if Oracle or other vendors have similar things.

Hope that helps...

On 1/24/08, Christopher Lamey <cl...@localmatters.com> wrote:
>
> So you want to change JDBC driver configuration based on the invoked
> method?
>
> For reporting reasons?
>
> I'm very curious, can you give more details?  An example?
>
> On 1/24/08 1:19 PM, "Hugh Ross" <hh...@gmail.com> wrote:
>
> > Unfortunately, the InvocationHandler for SimplePooledConnection is a
> private
> > nested class.
> >
> > Yes, we can set properties at the DataSource level, but we want to
> change it
> > at run time based on the data access "service" being invoked (e.g., for
> > finer-grain performance reporting).
> >
> >
> > On 1/24/08, Jeff Butler <je...@gmail.com> wrote:
> >>
> >> 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 <hh...@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 <je...@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 <hh...@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:
> >>>>>>
> >>>>>>
> http://opensource.atlassian.com/confluence/oss/pages/viewpage.action?page
> >>>>>> Id=15597591
> >>>>>>
> >>>>>>
> >>>>>> Jeff Butler
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> On Jan 24, 2008 10:03 AM, Hugh Ross <hh...@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!
> >>>>>>>
> >>>>>>
> >>>>>>
> >>>>>
> >>>>>
> >>>>
> >>>>
> >>>
> >>>
> >>
> >>
>
>

Re: How get DB2Connection object from SqlMapClient?

Posted by Hugh Ross <hh...@gmail.com>.
Thanks.  Looks like JDBC V4/Java 6 is adding a method to Connection itself
for this purpose.  That will make things a lot easier.

On 1/24/08, Jeff Butler <je...@gmail.com> wrote:
>
> Well...this is a real beauty of open source - you can easily change the
> inner class to public and recompile (you could also add the missing methods
> to the log proxy classes if you want to stay at 2.2).  I'll commit a
> change to make the inner class public so that your code won't break with
> future releases.
>
> Jeff Butler
>
>
>
> On Jan 24, 2008 2:19 PM, Hugh Ross <hh...@gmail.com> wrote:
>
> > Unfortunately, the InvocationHandler for SimplePooledConnection is a
> > private nested class.
> >
> > Yes, we can set properties at the DataSource level, but we want to
> > change it at run time based on the data access "service" being invoked (
> > e.g., for finer-grain performance reporting).
> >
> >
> >   On 1/24/08, Jeff Butler <je...@gmail.com> wrote:
> > >
> > > 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 <hh...@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 <hh...@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:
> > > > > > >
> > > > > > > http://opensource.atlassian.com/confluence/oss/pages/viewpage.action?pageId=15597591
> > > > > > >
> > > > > > >
> > > > > > > Jeff Butler
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > On Jan 24, 2008 10:03 AM, Hugh Ross <hh...@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!
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>

Re: How get DB2Connection object from SqlMapClient?

Posted by Jeff Butler <je...@gmail.com>.
Well...this is a real beauty of open source - you can easily change the
inner class to public and recompile (you could also add the missing methods
to the log proxy classes if you want to stay at 2.2).  I'll commit a change
to make the inner class public so that your code won't break with future
releases.

Jeff Butler



On Jan 24, 2008 2:19 PM, Hugh Ross <hh...@gmail.com> wrote:

> Unfortunately, the InvocationHandler for SimplePooledConnection is a
> private nested class.
>
> Yes, we can set properties at the DataSource level, but we want to change
> it at run time based on the data access "service" being invoked (e.g., for
> finer-grain performance reporting).
>
>
>   On 1/24/08, Jeff Butler <je...@gmail.com> wrote:
> >
> > 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 <hh...@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.3is 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 <hh...@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:
> > > > > >
> > > > > > http://opensource.atlassian.com/confluence/oss/pages/viewpage.action?pageId=15597591
> > > > > >
> > > > > >
> > > > > > Jeff Butler
> > > > > >
> > > > > >
> > > > > >
> > > > > > On Jan 24, 2008 10:03 AM, Hugh Ross <hh...@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!
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>

Re: How get DB2Connection object from SqlMapClient?

Posted by Christopher Lamey <cl...@localmatters.com>.
So you want to change JDBC driver configuration based on the invoked method?

For reporting reasons?

I'm very curious, can you give more details?  An example?

On 1/24/08 1:19 PM, "Hugh Ross" <hh...@gmail.com> wrote:

> Unfortunately, the InvocationHandler for SimplePooledConnection is a private
> nested class.
> 
> Yes, we can set properties at the DataSource level, but we want to change it
> at run time based on the data access "service" being invoked (e.g., for
> finer-grain performance reporting).
> 
> 
> On 1/24/08, Jeff Butler <je...@gmail.com> wrote:
>> 
>> 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 <hh...@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 <je...@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 <hh...@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:
>>>>>> 
>>>>>> http://opensource.atlassian.com/confluence/oss/pages/viewpage.action?page
>>>>>> Id=15597591
>>>>>> 
>>>>>> 
>>>>>> Jeff Butler
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> On Jan 24, 2008 10:03 AM, Hugh Ross <hh...@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!
>>>>>>> 
>>>>>> 
>>>>>> 
>>>>> 
>>>>> 
>>>> 
>>>> 
>>> 
>>> 
>> 
>> 


Re: How get DB2Connection object from SqlMapClient?

Posted by Hugh Ross <hh...@gmail.com>.
Unfortunately, the InvocationHandler for SimplePooledConnection is a private
nested class.

Yes, we can set properties at the DataSource level, but we want to change it
at run time based on the data access "service" being invoked (e.g., for
finer-grain performance reporting).


On 1/24/08, Jeff Butler <je...@gmail.com> wrote:
>
> 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 <hh...@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 <je...@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 <hh...@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:
> > > > >
> > > > > http://opensource.atlassian.com/confluence/oss/pages/viewpage.action?pageId=15597591
> > > > >
> > > > >
> > > > > Jeff Butler
> > > > >
> > > > >
> > > > >
> > > > > On Jan 24, 2008 10:03 AM, Hugh Ross <hh...@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!
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>

Re: How get DB2Connection object from SqlMapClient?

Posted by Jeff Butler <je...@gmail.com>.
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 <hh...@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 <je...@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 <hh...@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:
> > > >
> > > > http://opensource.atlassian.com/confluence/oss/pages/viewpage.action?pageId=15597591
> > > >
> > > >
> > > > Jeff Butler
> > > >
> > > >
> > > >
> > > > On Jan 24, 2008 10:03 AM, Hugh Ross <hh...@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!
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>

Re: How get DB2Connection object from SqlMapClient?

Posted by Hugh Ross <hh...@gmail.com>.
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 <je...@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 <hh...@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 <je...@gmail.com> 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 <hh...@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!
> > > >
> > >
> > >
> >
> >
>
>

Re: How get DB2Connection object from SqlMapClient?

Posted by Jeff Butler <je...@gmail.com>.
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 <hh...@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 <je...@gmail.com> 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 <hh...@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!
> > >
> >
> >
>

Re: How get DB2Connection object from SqlMapClient?

Posted by Hugh Ross <hh...@gmail.com>.
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 <je...@gmail.com> 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 <hh...@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!
> >
>
>

Re: How get DB2Connection object from SqlMapClient?

Posted by Jeff Butler <je...@gmail.com>.
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 <hh...@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!
>