Re: Using CopyManager with pooled JCA connection

Поиск
Список
Период
Сортировка
От Jim Garrison
Тема Re: Using CopyManager with pooled JCA connection
Дата
Msg-id 0C723FEB5B4E5642B25B451BA57E27303EE03383@S1P5DAG3C.EXCHPROD.USA.NET
обсуждение исходный текст
Ответ на Using CopyManager with pooled JCA connection  (Jim Garrison <jim.garrison@nwea.org>)
Ответы Re: Using CopyManager with pooled JCA connection  (Jim Garrison <jim.garrison@nwea.org>)
Re: Using CopyManager with pooled JCA connection  (Kris Jurka <books@ejurka.com>)
Список pgsql-jdbc
>From: Sehrope Sarkuni [mailto:sehrope@jackdb.com]
>Sent: Thursday, September 12, 2013 2:01 PM
>One other trick is that if you can get anything that implements java.sql.Connection you can usually get to the "raw"
connectionby first getting the DB meta data object and then getting the original connection from it.  
Spring has a decent explanation of in SimpleNativeJdbcExtractor[1]. Basically you do conn.getMetaData().getConnection()
>If that doesn't work try to programmatically dump the interfaces implemented by the value returned by
getPhysicalConnection()and see if any of those have an "unwrap" method on them. It's possible that the "physical
connection"is itself a wrapper of the actual connection. I know some connection pools do that. 

Looks like we're following the same path.  I almost had this working:

    private PGConnection getPGConnection(Connection con)
    {
        PGConnection temp = null;

        if (con instanceof ConnectionHandle)
        {
            Object pc = ((ConnectionHandle) con).getAssociation().getPhysicalConnection();
            temp = (PGConnection) pc;
        }
        else
            temp = (PGConnection) con;

        return temp;
    }

But unfortunately, the two connection objects (source and target databases) are loaded by different classloaders, so
thestatement 

    If (con instanceof ConnectionHandle)

Works for one but fails for the second.  I will try your getMetadata() suggestion



В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Jim Garrison
Дата:
Сообщение: Re: Using CopyManager with pooled JCA connection
Следующее
От: Jim Garrison
Дата:
Сообщение: Re: Using CopyManager with pooled JCA connection