pgsql jdbc db connection weird behaviour

From: Venkateswar Reddy Melachervu <vmelachervu(at)gmail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: pgsql jdbc db connection weird behaviour
Date: 2014-03-30 05:10:10
Message-ID: CAFbMEWUOehVa69xWYT7iS8RR8Uufn80DNchv9yVp=XtBf0MP9A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hello PGSQL Community,
Love pgsql. But facing this weird problem (detailed below) for past couple
of days with pgsql jdbc41 driver with tomcat 8 connection pooling on on
jvm1.8 (all on x64 windows 8) with no resolution in sight for casting a
jdbc db tomcat pooled connection to PGConnection hitting the wall.

I am sure not sure if I am doing something silly or it is the limitation of
pgsql jdbc41 driver. *Did any one face any such issue? Does any one know
some way out for this?*

*Problem:*
When I try to cast a DB Connection obtained using tomcat jdbc resource
(pooled) to org.postgresql.PGConnection, of course after unwrapping it,
execution is running into exception with the message:
*(java.lang.ClassCastException)
java.lang.ClassCastException: org.postgresql.jdbc4.Jdbc4Connection cannot
be cast to org.postgresql.PGConnection*

*Gotcha*
Weird enough, if I do not use a pooled connection but create a single db
stand-alone connection in the java code - dbCon = .getConnection(...) and
cast this to org.postgresql.PGConnection - to my surprise - it's
successful. Feels weird!

*Environment*
OS : WIndows 8 x64
JRE : java version "1.7.0_51"
Tomcat : 8.0 (x64)
Connection pooling : Tomcat jdbc connection pooling with database as JDBC
resource (org.apache.tomcat.jdbc.pool.DataSourceFactory)
PostgreSQL server : v9.3 x64
Pgsql JDBC version : JDBC41 Postgresql Driver, Version
9.3-1101<http://jdbc.postgresql.org/download/postgresql-9.3-1101.jdbc41.jar>
(stored
in Tomcat lib dir and linked from there to my project)

--
Regards,
Venkateswar Reddy Melachervu
"...dare to dream, care to win..."
www.linkedin.com/in/vmelachervu

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Steven Schlansker 2014-03-30 05:29:22 Re: pgsql jdbc db connection weird behaviour
Previous Message Mike Fowler 2014-03-28 23:05:34 JDBC Buildfarm upgraded (Re: link to file bug against Postgres JDBC driver)