• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Connect my liferay portlet with jdbc driver

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 !
 
Saloon Keeper
Posts: 2619
329
Android Eclipse IDE Angular Framework MySQL Database TypeScript Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Franck Might wrote:.. my portlet does not see jdbc


It's not clear (to me anyway) what this means.  Are there errors reported when compiling your your code, or maybe run-time errors?
 
Bartender
Posts: 20842
125
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!