• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC connection error with JNDI resource

 
Sanjib Pal
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • 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


 
Jan Cumps
Bartender
Posts: 2588
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am moving this to our Tomcat forum.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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
  • 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
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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
  • 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
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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.
 
Michael Tarimo
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic