Patch so Pooled Connections are PGConnections

From: Aaron Mulder <ammulder(at)alumni(dot)princeton(dot)edu>
To: "'pgsql-jdbc(at)postgresql(dot)org'" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Patch so Pooled Connections are PGConnections
Date: 2003-01-03 20:24:42
Message-ID: Pine.LNX.4.44.0301031518530.13966-300000@www.princetongames.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Here's a patch that demonstrates the problem in the test class and
fixes it in the pooled connection class. This makes all pooled
connections implement PGConnection (in addition to java.sql.Connection),
so if you use the PostgreSQL connection pools you can still use the
PGConnection API. Still won't help if you use the native Tomcat pools,
but you can always use the PostgreSQL pools in Tomcat.

Aaron

On Fri, 3 Jan 2003, Aaron Mulder wrote:
> When you use a DataSource, the connection returned is not an
> org.postgresql.PGConnection, so the ClassCastException would be expected.
> The connection is usually wrapped (though I'd have to look at the Tomcat
> impl to be sure) because the behavior is supposed to be different for
> pooled connections (in particular, close, and often setAutoCommit).
> Now that I look at it, we could easily enough make the PostgreSQL
> pooled connections implement PGConnection, and then you could just use the
> PostgreSQL DataSource instead of the Tomcat DataSource.
>
> Aaron
>
> On Fri, 3 Jan 2003, Joao Filipe Placido wrote:
> > Hello list,
> >
> > I configured successfully a PostgreSQL 7.2.3 connection pool with JNDI
> > DataSource following the Tomcat docs (v 4.1.12).
> > But when I try to use the returned connection with the LargeObjectAPI,
> > tomcat gives me a ClassCastException (runtime), in the following line:
> >
> > LargeObjectManager lobj =
> > ((org.postgresql.PGConnection)db).getLargeObjectAPI();
> >
> > I tried using pgjdbc2.jar, in which case instead of
> > org.postgresql.PGConnection, it only works with org.postgresql.Connection.
> > With pg73jdbc3.jar, and using org.postgresql.PGConnection, the same
> > Exception occurs.
> > I also tried with a compiled JDBC jar from the 7.3 sources, with no luck.
> >
> > I don't understand why the connection works with non-LargeObject SQL and
> > fails here. I have the same jars working with the LargeObjectAPI without the
> > Tomcat DBCP.
> > Any help is appreciated. Has anyone successfully configured a tomcat DBCP
> > with PostgresSQL and used LOs with it?
> >
> > Thank you,
> >
> > João Filipe Plácido
> >
> >
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>

Attachment Content-Type Size
PooledConnectionImpl.diff text/plain 1.9 KB
BaseDataSourceTest.diff text/plain 1.3 KB

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Hilmar Lapp 2003-01-03 22:09:02 Re: join over 12 tables takes 3 secs to plan
Previous Message Barry Lind 2003-01-03 20:10:57 Re: [GENERAL] 7.3 Prepared statements