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,753
  • 2
  • 30
  • 49
himAndroid
  • 1,671
  • 3
  • 13
  • 12

2 Answers2

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

Community
  • 1
  • 1
k_ssup
  • 338
  • 1
  • 8
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 .

Mohammod Hossain
  • 4,134
  • 2
  • 26
  • 37