MySQL Forums
Forum List  »  Microsoft SQL Server

Re: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Posted by: irfan u
Date: April 20, 2007 12:14AM

I am getting java.lang.ClassNotFoundException: com.mysql.jdbc.Driver rxception when i try to connect mysql
here is my code
import java.sql.*;


public class Connect
{
public static void main (String[] args)
{
Connection conn = null;

try
{
String userName = "root";
String password = "irfan";
String url = "jdbc:mysql://localhost/irfan";
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection (url,userName,password);
System.out.println ("Database connection established");
}
catch (Exception e)
{
System.err.println ("Cannot connect to database server"+e);
}
finally
{
if (conn != null)
{
try
{
conn.close ();
System.out.println ("Database connection terminated");
}
catch (Exception e) { /* ignore close errors */ }
}
}
}
}

Options: ReplyQuote


Subject
Written By
Posted
Re: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
April 20, 2007 12:14AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.