aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes where to add mysqlconnector jar in eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "where to add mysqlconnector jar in eclipse" Watch "where to add mysqlconnector jar in eclipse" New topic
Author

where to add mysqlconnector jar in eclipse

vijayakumar durai
Ranch Hand

Joined: Aug 18, 2008
Posts: 153
i am using servlet and mysql i placed jar file in webinf->lib but it tell class not found error in eclipse

org.gtj.mm.mysql.Driver class not found exception

can anybody tell where to place mysqlconnector.jar in eclipse?






thanks in advance





David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You should add it to the specific project you're working on, either by importing it into a library directory, putting it in WEB-INF/lib if it's a web app, or use it as an external jar.

I'd also recommend using the com.mysql.jdbc.Driver class (or whatever it's called; I don't remember) instead of the very old compatibility driver name.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5830
    
    7

If you are correctly coding to the JDBC spec, and not using database-specific functionality, you should not need to include the MySQL JDBC driver JAR file in your project - the JDBC API is all in the JDK runtime JAR.


JBoss In Action
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

What? I don't see how you could just use MySQL through JDBC without the MySQL connector. All databases supply their own JDBC drivers. How would you instantiate a driver?
vijayakumar durai
Ranch Hand

Joined: Aug 18, 2008
Posts: 153
thank you friends i got result i download new mysql connector jar file and place it in web-inf ->lib its working
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16065
    
  21

This sounds like the classical confusion between the IDE and the deployable application.

The ONLY time you need to put ANY database driver "in Eclipse" is if you have an Eclipse tool such as one of the database management plug-ins and you need to tell the plug-in where to find the driver.

For general app development, Eclipse could care less (and in fact, has no use for databases). In that case, what you really want is to make the driver available to the application. And, specifically, if Eclipse is managing a web application server for debugging purposes, to that application server environment. And, as in general databases, Eclipse doesn't know nor does it care about web application servers. Only an installed plugin for webapp development such as sysdeo or WTP will care.

Normally, you should not put application libraries in your webapp server's private libraries, you should put them in the webapp's WEB-INF/lib directory. One of the few exceptions is JDBC drivers. Normally, you'd want to place things like the mysql connector jar in the server's common library directory (for example, CATALINA_HOME/lib, for Tomcat). That's because unlike most Java code, the drivers are intended to be shared between multiple applications, and may, in fact, do better resource management if they do. It also insulates your webapps from dependence on a particular driver/version and makes them somewhat more portable.


Customer surveys are for companies who didn't pay proper attention to begin with.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5830
    
    7

When the OP mentioned an Eclipse error, I assumed that it was a compile error. The OP was not clear on this topic. As Tim pointed out, there is a big difference between building an app that uses JDBC and running it - you don't need the driver to build it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: where to add mysqlconnector jar in eclipse