I had written the program JDBCConnection. i.e.,
Here admin is mysql password.Code:import java.sql.*; public class Connect { public static void main (String[] args) { Connection conn = null; try { String userName = "Root"; String password = "admin"; String url = "jdbc:mysql://localhost:3306/test"; 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"); } } }
I had copied the mysql-connector-java-5.0.8-bin.jar file in the location of C:\Program Files\Java\jdk1.5.0\jre\lib folder and set the class path as same path.
When i had compile the program it has compile successfully. But when i was runeed it has displayed an error message.
i.e.,
Exception in thread "main" java.lang.NoClassDefFoundError: Connect
Please tell me what is the mistake any one knows.


Reply With Quote


Bookmarks