java.lang.ClassCastException: org.postgresql.jdbc4.Jdbc4Connection cannot be cast to org.postgresql.jdbc4.Jdbc4Connection

Posted by ???????? ?????? on Stack Overflow See other posts from Stack Overflow or by ???????? ??????
Published on 2014-08-24T16:17:41Z Indexed on 2014/08/24 16:19 UTC
Read the original article Hit count: 874

I want to get PGConnection from posgresql connection in JBOSS AS7 (Data source postgresql-9.0-801.jdbc4.jar) I've got cast exception when used (WrappedConnection)connection So now I use reflection(JDK 1.7): private static PGConnection getPGConnection(Connection connection) throws SQLException { if(connection instanceof PGConnection) { return (PGConnection)connection; } try { Class[] parms = null; Method method =(connection.getClass()).getMethod("getUnderlyingConnection", parms); return (PGConnection) jdbc4Conn; } catch ... and catch exception java.lang.ClassCastException: org.postgresql.jdbc4.Jdbc4Connection cannot be cast to org.postgresql.jdbc4.Jdbc4Connection It is the same class!!! Haw could it be?

© Stack Overflow or respective owner

Related posts about java

Related posts about postgresql