pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
ClassCastException org.postgresql.jdbc3.Jdbc3Connection
2+ messages / 1 participants
[nested] [flat]

* ClassCastException org.postgresql.jdbc3.Jdbc3Connection
@ 2006-08-11 14:52 Prasanth <dbadmin@nqadmin.com>
  2006-08-11 16:28 ` Re: ClassCastException org.postgresql.jdbc3.Jdbc3Connection Prasanth <dbadmin@nqadmin.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Prasanth @ 2006-08-11 14:52 UTC (permalink / raw)
  To: pgsql-jdbc

I am trying to get the PGConnection/Jdbc3Connection object from
Connection class.
The connection class returned is
org.jboss.resource.adapter.jdbc.WrappedConnection (as I am using JNDI in
JBoss).

When I try to get the underlying connection and cast it to
Jdbc3Connection I am getting a class cast exception.

Below is the code.
Connection conn =
((WrappedConnection)DBConnection.getConnection()).getUnderlyingConnection();
LargeObjectManager lobj =
((org.postgresql.jdbc3.Jdbc3Connection)conn).getLargeObjectAPI();

In the above code DBConnection class provides a method to get the
connection object from the pool.

Exception:
09:42:33,016 WARN  [RequestProcessor] Unhandled Exception thrown: class
java.lang.ClassCastException
09:42:33,017 ERROR [[action]] Servlet.service() for servlet action threw
exception
java.lang.ClassCastException: org.postgresql.jdbc3.Jdbc3Connection


As you can see it says that the object is of type Jdbc3Connection so why
does it give a class cast exception then?

I am using  postgresql-8.1-404.jdbc3.jar driver & the database is 8.1.3.

Thanks,
-Prasanth.



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: ClassCastException org.postgresql.jdbc3.Jdbc3Connection
  2006-08-11 14:52 ClassCastException org.postgresql.jdbc3.Jdbc3Connection Prasanth <dbadmin@nqadmin.com>
@ 2006-08-11 16:28 ` Prasanth <dbadmin@nqadmin.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Prasanth @ 2006-08-11 16:28 UTC (permalink / raw)
  To: ; +Cc: pgsql-jdbc

I think I got it. The server had a jar & my WAR has the same jar.
Probably the JNDI used the jar in the server while my application used
the class from the jar in the WAR.
As these are two different class files I was getting the class cast
exception.

-Prasanth.

Prasanth wrote:
> I am trying to get the PGConnection/Jdbc3Connection object from
> Connection class.
> The connection class returned is
> org.jboss.resource.adapter.jdbc.WrappedConnection (as I am using JNDI in
> JBoss).
>
> When I try to get the underlying connection and cast it to
> Jdbc3Connection I am getting a class cast exception.
>
> Below is the code.
> Connection conn =
> ((WrappedConnection)DBConnection.getConnection()).getUnderlyingConnection();
> LargeObjectManager lobj =
> ((org.postgresql.jdbc3.Jdbc3Connection)conn).getLargeObjectAPI();
>
> In the above code DBConnection class provides a method to get the
> connection object from the pool.
>
> Exception:
> 09:42:33,016 WARN  [RequestProcessor] Unhandled Exception thrown: class
> java.lang.ClassCastException
> 09:42:33,017 ERROR [[action]] Servlet.service() for servlet action threw
> exception
> java.lang.ClassCastException: org.postgresql.jdbc3.Jdbc3Connection
>
>
> As you can see it says that the object is of type Jdbc3Connection so why
> does it give a class cast exception then?
>
> I am using  postgresql-8.1-404.jdbc3.jar driver & the database is 8.1.3.
>
> Thanks,
> -Prasanth.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>   



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2006-08-11 16:28 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-08-11 14:52 ClassCastException org.postgresql.jdbc3.Jdbc3Connection Prasanth <dbadmin@nqadmin.com>
2006-08-11 16:28 ` Prasanth <dbadmin@nqadmin.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox