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

Re: Installtion problem of MySql JDBC driver JConnector 5.0 80 80

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();
}
}


}
Re: Installtion problem of MySql JDBC driver JConnector 5.0 80 80

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

Class.forName("com.mysql.jdbc.Driver").newInstance();
Re: Installtion problem of MySql JDBC driver JConnector 5.0 80 80

have you placed the .jar file here???

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

i think you need to do that

Re: Installtion problem of MySql JDBC driver JConnector 5.0 80 80

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

Re: Installtion problem of MySql JDBC driver JConnector 5.0 80 80

Anyways sorry for late reply

Re: Installtion problem of MySql JDBC driver JConnector 5.0 80 80

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

Re: Installtion problem of MySql JDBC driver JConnector 5.0 80 80

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 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.