0

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

2
Contributors
1
Reply
3
Views
11 Years
Discussion Span
Last Post by jwenting
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.