File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Files in WEB-INF/lib Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Files in WEB-INF/lib" Watch "Files in WEB-INF/lib" New topic
Author

Files in WEB-INF/lib

raghu dubey
Ranch Hand

Joined: Jul 05, 2007
Posts: 72
I placed mysql driver jar file in the WEB-INF/lib but it did not work and I could not get the connection till I placed the file manually in the system classpath. Here is the code and web.xml config I used. Do I need to do anything else as well apart from doing things below. Also I do not think any import is required when using FQ class name of the driver. Please help.


Class.forName(getServletConfig().getServletContext().getInitParameter("dbDriver"));
Connection con = DriverManager.getConnection(getServletConfig().getServletContext().getInitParameter("dbURL"), "raghu","raghu123");

<context-param>
<param-name>dbDriver</param-name>
<paral-value>com.mysql.jdbc.Driver</param-value>
</context-param>


Thanks,<br />Raghu.<br /> <br />SCJP 5, SCWCD 1.4, NCFM
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

till I placed the file manually in the system classpath.

Which file ?


[My Blog]
All roads lead to JavaRanch
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3355

I believe he says the mysql connector jar file. Is nt it?


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
raghu dubey
Ranch Hand

Joined: Jul 05, 2007
Posts: 72
Hi Christophe,

Yes it is the mysql Db driver jar file.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

It should be working if it's put in WEB-INF/lib. The problem may be somewhere else.
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2267
    
    3

Howdy, y'all.

Indeed, it should be working, Chris is right.
If you put your .jar file in your Tomcat/lib folder, it will work not only for this particular application, but also for all the other applications you may have. But yet, this is a workaround, it should be working if you put the .jar file in the WEB-INF/lib folder of your application.
Well, try unistalling your Tomcat (you're using Tomcat, right?) and installing it again... it might work...


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

raghu, are you using an IDE like Eclipse and running your Tomcat instance inside of the IDE? If so, that would explain the problem. In Eclipse, you'd have to right-click the jars under WEB-INF/lib and select the option for adding them to your Build Path.


A good workman is known by his tools.
raghu dubey
Ranch Hand

Joined: Jul 05, 2007
Posts: 72
Nope Mark,

I am not using eclipse as of now. Just manual coding. I will try Bob's recipe and revert soon.
 
 
subject: Files in WEB-INF/lib