Accorting to MySql manual and web site I modified the environment variable for installing JConnector for mysql as follows :

CLASSPATH

C:\Program Files\Java\mysql-connector-java-5.0.7\mysql-connector-java-5.0.7-bin.jar

where my MySql connector Folder is placed on Java folder in program files (I put there willingly)

But actually when I want to do any testing program checking whether mysqlConnection is ok I get NoClassDefFound Exception that mean connection is not established and jConnector is not installed properly

PLz Tell me how can I install JConnector 5.0 I really need help

Here is my code

import java.sql.*;
import java.io.*;
import java.util.*;
import java.lang.Exception;


public class prog1 {


public prog1() {
}


public static void main (String[] args) {


try {


try{
Class.forName("Driver");
String url="jdbc:mysql://localhost/company?user=root&password=password";
Connection dbcon=DriverManager.getConnection(url,"root","password");
Statement smnt=dbcon.createStatement();
String query="select ENAME from emp";
ResultSet rs=smnt.executeQuery(query);
ResultSetMetaData resmetadata=rs.getMetaData();
int n=resmetadata.getColumnCount();
boolean more=rs.next();
System.out.println("The no of employee in the company"+n);
while(more)
{
rs.getString(1);
}


}
catch(ClassNotFoundException exp)
{
System.out.println("The Error is"+exp);
exp.getMessage();
exp.getStackTrace();
}


}
catch(SQLException sqle)
{
System.out.println("The Error is"+sqle);
sqle.getStackTrace();
}
}


}

You need to specify the full name of the driver in the Class.forName() call:

Class.forName("com.mysql.jdbc.Driver").newInstance();

have you placed the .jar file here???

C:\ProgramFiles\Java\jdk1.6.0_01\jre\lib\ext

i think you need to do that

I have solved the problem when working with netbeans and jcreator but for command line the scenario is the same

& I ve placed what you ve said to put in jre but nothing happened

Anyways sorry for late reply

how did u solve that, plz tell me. even m facing the same problem

C:\ProgramFiles\Java\jdk1.6.0_01\jre\lib\ext

Do not do this, it is wrong advice and bad idea to mess up with Java installation directory.

how did u solve that, plz tell me. even m facing the same problem

As you did not explain your problem I can give you general direction. Have look at this post which gives you quick guidelines how to add connector to your project in NetBeans. If this is not what you looking for please, explain more in depth your issue with database connector

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.