i am trying to connect java program to mysql databse. bascically i am aphp programmer. now i want to lear j2ee so i was trying to connect to mysql database.i am getting the error as not able to load the drive
thi sis my code
import java.sql.*;

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

try
{
Class.forName("MySql ODBC 3.51 Driver");
}

catch (Exception e)
{
System.err.println("Unable to load driver.");
e.printStackTrace();
return;
}

try {

con = DriverManager.getConnection(
"jdbc:mysql://localhost/login?user=nagaraja sastry&password=g86iyug");


System.out.println("Connection successful!");
System.out.println("I AM IN THE TEST DATABASE!"); }

catch(SQLException e)
{ e.printStackTrace(); }

finally { if (con != null )
{
try { con.close();
System.out.println("I HAVE CLOSED THE CONNECTION TO THE DATABASE!");
}
catch (SQLException e )
{ e.printStackTrace(); }
} //if
} //finally
} //main
} //tcdb
anybody pls help me
tahnks

Class.forName("MySql ODBC 3.51 Driver");

and you wonder why it won't load?
Go read the documentation...

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.