It seems that the connection that I got can't be casted to PGconnection :
java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper cannot be cast to org.postgresql.PGConnection at Test.DataBaseConnector.connection(DataBaseConnector.java:134) at Test.DataBaseConnector.<init>(DataBaseConnector.java:94) at Test.Guardian_Process.<init>(Guardian_Process.java:36) at Test.ServletListener.contextInitialized(ServletListener.java:36) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4600) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5097) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5092) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)