0

I have downloaded the following:

Now I have started programming with Eclipse. I have made simple java class like below,

public class MySQLAccess {
 private static Connection connect = null;
 private Statement statement = null;
 private PreparedStatement preparedStatement = null;
 private ResultSet resultSet = null;
 public static void main(String[] args){
 try{
 Class.forName ("com.mysql.jdbc.Driver").newInstance (); 
 }catch (Exception e) {
 // TODO: handle exception
 System.out.println("Error : "+e);
 } 
 } 
}

I have also made a folder "lib" in my Java project and I have put that mysql-connector jar over there. But when I run this program it can't find mysql I get the following error in the console :

Erro : java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

Can someone please tell me where I have made the mistake? Thank you

Sujay
6,7812 gold badges32 silver badges49 bronze badges
asked Aug 26, 2012 at 8:08

2 Answers 2

2

Putting the full jar-file path in your classpath and restarting cmd (if you are running from cmd) should work-

See here- java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

answered Aug 26, 2012 at 8:17
Sign up to request clarification or add additional context in comments.

Comments

0

If it your java application project then you put jar file into jdk library path ext folder.

eg:
C:\Program Files\Java\jdk1.6.0_13\jre\lib\ext

you will get path from your project class path .

answered Aug 26, 2012 at 8:23

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.