Signup · Login
Stardeveloper.com  
Home · Tutorials · Forums · ASP.NET Newsletter Application · Web Hosting Plans · Faisal Khan's Blog · Contact
Forums : J2EE : JDBC : Exception:com.mysql.jdbc.Driver Signup · Login
Author Thread
Exception:com.mysql.jdbc.Driver
Posted in tutorial: Installing and Configuring MySQL Database and Connector/J JDBC Driver on Microsoft Windows
·  gauri
User
Joined: 20 Jul 2004
Total Posts: 1

Exception:com.mysql.jdbc.Driver

Posted: 20 Jul 2004
Hi,

I have downloaded the connector /J 3.0.14 version just recently. I am using your program JdbcExample2 to try and connect to the mysql server. However i kep getting this error:

Exception:com.mysql.jdbc.Driver

I have tried setting my classpath var in following ways:

a> c:\mysql-connecor-java-3.0.14-production\mysql-connector-java-3.0.14-production.jar;
b> c:\connector\com;c:\connector\org;
c> put the jar file into java\lib\ext dir.

nothing works.........is your tutorial correct? or does it need some corrections? I have tried every possible solution.
please let me know ASAP as I have been working on this problem for abt 10 days now.
Thanks/
·  sukrus
User
Joined: 22 Jul 2004
Total Posts: 3
Follow Carefully
Posted: 22 Jul 2004
The first thing you should do is setting your classpath variables inside java (including mysql connector .jar file and the root folder) if you do not use a java ide it is hard(i'm using netbeans ide and you can do it by choosing tools->options->execution and dubuging->external execution here you will see properties window on the right side click to expert button will see classpath text field and choose your mysql connector. It is the same for both 3.5 and 3.6 version of netbeans)and a connection testing code for you:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.*;

// Notice, do not import com.mysql.jdbc.*
// or you will have problems!

public class LoadDriver
{
public static void main(String[] args) {
try
{

Class.forName("com.mysql.jdbc.Driver").newInstance();
}
catch (Exception ex) {
// handle the error
}

try {
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/new");//this is your db name(new)
System.out.println("Ok hoca bu iž de halloldu!!");
ResultSet rst=null;
Statement stmt=null;
// String str="create table new (Name varchar(22),Surname varchar(22))";
String str2="insert into new values('Umit','Sadeguzel')";
stmt=conn.createStatement();
// stmt.executeUpdate(str);
stmt.executeUpdate(str2);

// Do something with the Connection


}
catch (SQLException ex) {
// handle any errors
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}

}
}
·  passionforJavaJ2ee
User
Joined: 24 Jul 2004
Total Posts: 4
problem Exception:com.mysql.jdbc.Driver
Posted: 24 Jul 2004
Hey stardeveloper,

I have read quite a few tutorials from ur website and I would like to thank you for these awsome tutorials. There are hundreds of tutorials out there on the net but your tutorials are unbelievably good. The language, the content including most common problems etc....Keep up the good work. Thanks again,

Now the problem,
I have done the exact same steps to install and configure mysql 4.0 and connectorJ 3.0. But now, in order to test the connector...I am trying to run your testprogram and it gives me
Exception:com.mysql.jdbc.Driver

......Its strange cause, I have everything needed in my classpath environment variable. have a look,

CLASSPATH->

.;C:\j2sdk1.4.2_04\bin;C:\j2sdk1.4.2_04\lib;C:\j2sdk1.4.2_04\lib\tools.jar;C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar;C:\j2sdk1.4.2_04\jre\lib\ext\mysql-connector-java-3.0.14-production-bin.jar

Now, plz could you or anyone suggest me why the hell am I getting this exception. I would be thankful to you if I can get the answer quickly.
Cheers!

Just want to learn everything related to Java
·  passionforJavaJ2ee
User
Joined: 24 Jul 2004
Total Posts: 4
problem Exception:com.mysql.jdbc.Driver
Posted: 24 Jul 2004
Hey stardeveloper,

I have read quite a few tutorials from ur website and I would like to thank you for these awsome tutorials. There are hundreds of tutorials out there on the net but your tutorials are unbelievably good. The language, the content including most common problems etc....Keep up the good work. Thanks again,

Now the problem,
I have done the exact same steps to install and configure mysql 4.0 and connectorJ 3.0. But now, in order to test the connector...I am trying to run your testprogram and it gives me
Exception:com.mysql.jdbc.Driver

......Its strange cause, I have everything needed in my classpath environment variable. have a look,

CLASSPATH->

.;C:\j2sdk1.4.2_04\bin;C:\j2sdk1.4.2_04\lib;C:\j2sdk1.4.2_04\lib\tools.jar;C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar;C:\j2sdk1.4.2_04\jre\lib\ext\mysql-connector-java-3.0.14-production-bin.jar

Now, plz could you or anyone suggest me why the hell am I getting this exception. I would be thankful to you if I can get the answer quickly.
Cheers!

Just want to learn everything related to Java
·  passionforJavaJ2ee
User
Joined: 24 Jul 2004
Total Posts: 4
problem Exception:com.mysql.jdbc.Driver
Posted: 24 Jul 2004
Hey stardeveloper,

I have read quite a few tutorials from ur website and I would like to thank you for these awsome tutorials. There are hundreds of tutorials out there on the net but your tutorials are unbelievably good. The language, the content including most common problems etc....Keep up the good work. Thanks again,

Now the problem,
I have done the exact same steps to install and configure mysql 4.0 and connectorJ 3.0. But now, in order to test the connector...I am trying to run your testprogram and it gives me
Exception:com.mysql.jdbc.Driver

......Its strange cause, I have everything needed in my classpath environment variable. have a look,

CLASSPATH->

.;C:\j2sdk1.4.2_04\bin;C:\j2sdk1.4.2_04\lib;C:\j2sdk1.4.2_04\lib\tools.jar;C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar;C:\j2sdk1.4.2_04\jre\lib\ext\mysql-connector-java-3.0.14-production-bin.jar

Now, plz could you or anyone suggest me why the hell am I getting this exception. I would be thankful to you if I can get the answer quickly.
Cheers!

Just want to learn everything related to Java
·  passionforJavaJ2ee
User
Joined: 24 Jul 2004
Total Posts: 4
Partial Solution to the Problem
Posted: 25 Jul 2004
Hello everyone,

I tried searchin on google and found solution to this problem. Hint was for somebody using JCreator..but it worked in my simple BlueJ too. All we need to do is, add the jar file (into the libraries to be used) of the JCreator or BlueJ whichever u'r using.

This solved the problem with this JavaEditor but I still am not sure gettin it to run on cmd. It gives me NoClassDefFound Exception, ofcourse for com.mysql.jdbc.Driver. Any Genious minds?

Just want to learn everything related to Java
Want to leave a comment? Login or Register for free!

Users Who Have Visited This Thread In Last 24 Hours
35 Visitors

Login to post a comment or start a new thread
UserName Or Email Address:       Password:       Auto-Login:    
· Create New User Account
· Send Forgotten Password by Email
 
© 1999 - 2010 Stardeveloper.com, All Rights Reserved.