0

I am trying to connect to mysql in java (I use Wamp) so I used the following code : (I'm using Eclipse)

package genererPlanning;
import java.sql.*;

public class genererPlanning{
    static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
    static final String DB_URL = "jdbc:mysql://localhost/mysql";

    static final String USER = "root";
    static final String PASS = "";

    public static void main(String[] args){
        Connection conn = null;
        try {
            conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root", "");
        }
        catch (SQLException ex){
            System.out.println("SQLException: " + ex.getMessage());
            System.out.println("SQLState: " + ex.getSQLState());
            System.out.println("VendorError: " + ex.getErrorCode());
        }
    }
}

But it returned me this text :

SQLException: No suitable driver found for jdbc:mysql://localhost:3306/mysql
SQLState: 08001
VendorError: 0

Do you know why it does not work?
PS : I looked at theses links but don't find my answer :
- stackoverflow
- stackoverflow
- stackoverflow
- commentcamarche

Thanks for all.

4
  • 1
    Do you have the mysql driver lib (jar file) in your build path? Commented May 27, 2015 at 10:38
  • 1
    You miss the mysql-connector.jar in your classpazth Commented May 27, 2015 at 10:38
  • Indeed, this was not mentioned in the tutorial. Can you tell me where to find ( and add) this .jar please ? Commented May 27, 2015 at 10:41
  • All the linked questions answer the question - apparently you can't recognize it as an answer. Do you know how to work with jar libraries and/or the Java classpath? Commented May 27, 2015 at 11:25

2 Answers 2

1

You need to use the mysql-connector.jar

Here's the link with instructions as to how to set it to your classpath.

http://code.google.com/p/find-ur-pal/downloads/detail?name=mysql-connector-java-5.1.18-bin.jar&

Sign up to request clarification or add additional context in comments.

Comments

1

You need mysql jdbc connector..download from this site

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.