I want to connect my portlet to postgresql. But my portlet does not see jdbc. In my portlet package I have two classes. Connection.java and TestDBPortlet.java. Connection.java successfully connects to postgresql but TestDBPortlet.java does not see jdbc. Is this normal knowing that both are in the same package, they must have the same classes? I have copy jbdc.jar in tomcat/libs, tomcat/lib/ext and tomcat/webapps/root/web-inf/libs but nothing changes. Help me please !
You should not put application libraries in Tomcat's lib directory. ONLY jars used by Tomcat itself go there. Jars used by a web application should be placed in the webapp's WAR in /WEB-INF/libs.
In the case of JDBC drivers, recommended procedure is to use a JDBC Connection Pool, which is an object created and owned by the webapp server (Tomcat), and therefore the JDBC Driver jar must be put in Tomcat's lib directory and NOT in the WAR.
The webapp locates the JDBC Connection Pool using JNDI. Once the app has a handle on the pool, app requests can use the pool's getConnection() method to obtain a Connection and the Connection's close() method to return the Connection back to the pool. Which should be done as soon as you're done using it for maximum efficiency. And NEVER carried from one Http request to another.
When it comes to destroying a civilization, gas chambers cannot hold a candle to echo chambers.