• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JDBC connection error with JNDI resource

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have a problem of JDBC connection with PostgreSQL and Apache Tomcat. I have tried to create a JNDI resource and get connection with the use tins resource but failed. I am getting an exception as



My context.xml under META-INF folder is as



My web.xml is as



and my jsp code is as



I am using

Apache Tomcat 6.0.13
JVM 1.5
PostgreSQL 8.4
JDBC Connector postgresql-8.4-701.jdbc3.jar
DBCP jar commons-dbcp-1.3.jar
POOL jar commons-pool-1.3.jar
JSTL jar jstl-1.2.jar


Please give me suggestion, how can I solve this.

Thanks in advance,

Sanjib Pal


 
Bartender
Posts: 2661
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am moving this to our Tomcat forum.
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Place the postgresql j2ee (driver) jar in the TOMCAT_HOME/lib directory. Don't include it in your WAR.
 
Sanjib Pal
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim Holloway,

Thanks for your suggestion, but one problem is there how can I find the $TOMCAT_HOME/lib directory in MyEclipse? I have uploaded the jar file in WEB-INF/lib directory.

With Beat Regards,
Sanjib Pal
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sanjib Pal wrote:Hi Tim Holloway,

Thanks for your suggestion, but one problem is there how can I find the $TOMCAT_HOME/lib directory in MyEclipse? I have uploaded the jar file in WEB-INF/lib directory.

With Beat Regards,
Sanjib Pal



I know almost nothing about MyEclipse. In most J2EE Eclipse plugins Tomcat is an external program.

DON'T put the database driver in the WEB-INF/lib directory. WEB-INF is part of your WAR, and I already said that the driver jar should not be included in the WAR.
 
Sanjib Pal
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim Holloway,

I have put the database driver in the $TOMCT_HOME/lib directory but same exception is occuring.

Please help me.

Thanks,
Sanjib
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sanjib Pal wrote:Hi Tim Holloway,

I have put the database driver in the $TOMCT_HOME/lib directory but same exception is occuring.

Please help me.

Thanks,
Sanjib



At this point, I can only suggest 2 things.

1. Make sure you have removed postgresql's driver jar from your WAR.

2. Make sure that your "$TOMCT_HOME/lib" directory is, in fact, the library directory for the copy of Tomcat that you're trying to work with. And that you completely shut down and restarted Tomcat.

If you have done those 2 things correctly, the DBCP manager should have no trouble finding the driver.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The bottom line is the driver needs to go to the TOMCAT lib.
If you are using MyEclipse;
Go to preferences (Window > Preferences), then Servers > Integrated Sandbox > MyEclipse Tomcat <version> > Paths
Under prepend to calsspath, add the jar.

This should make it work.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic