File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes JDBC connection error with JNDI resource Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "JDBC connection error with JNDI resource" Watch "JDBC connection error with JNDI resource" New topic
Author

JDBC connection error with JNDI resource

Sanjib Pal
Greenhorn

Joined: Feb 08, 2010
Posts: 27
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



SCJP 5.0
Try unless you get the ultimate success.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2491
    
    8

I am moving this to our Tomcat forum.


OCUP UML fundamental and ITIL foundation
youtube channel
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15958
    
  19

Place the postgresql j2ee (driver) jar in the TOMCAT_HOME/lib directory. Don't include it in your WAR.


Customer surveys are for companies who didn't pay proper attention to begin with.
Sanjib Pal
Greenhorn

Joined: Feb 08, 2010
Posts: 27
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

Joined: Jun 25, 2001
Posts: 15958
    
  19

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

Joined: Feb 08, 2010
Posts: 27
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

Joined: Jun 25, 2001
Posts: 15958
    
  19

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

Joined: Jul 21, 2012
Posts: 1
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC connection error with JNDI resource
 
Similar Threads
Trouble Configuring a Data Source for MySQL using JSTL in JBoss
Trouble in retrieving data from the mysql database using JSTL
DataSource Invalid
Error:Unable to get connection, DataSource invalid
Simple JDBC problem - Connection throws Nullpointerexception