Hi! I have installed Apacha Tomcat 7 ,mysql 5.5 and eclipse 4.2.I copied mysql-connector-java-5.1.20-bin.jar to Apache/lib folder.When I make wizard based connection.The connection establishes successfully.But when I use programming
package DataAccessWithJava;
import java.sql.*;
import java.lang.*;
public class MysqlConnect{
public static void main(String[] args) {
System.out.println("MySQL Connect Example.");
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/test";
String dbName = "test";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "root";
try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName,userName,password);
System.out.println("Connected to the database");
conn.close();
System.out.println("Disconnected from database");
} catch (Exception e) {
e.printStackTrace();
}
}
}
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver this error occurs and no help is available
jdbcamrita singh April 22, 2011 at 4:16 PM
nice
Comple Advance javaKhan Tauseef Ahmed July 3, 2011 at 3:09 PM
JDBC explanation is Best.
about the scriptbhagya November 14, 2011 at 11:14 AM
Its very informative for beginners...
database driverpatel vishal February 2, 2012 at 11:42 AM
Why i am not created access and SQL database driver in java? Any software required?
JDBC driver not working for Eclipse 4.2 IDEAdeel Ahmed May 21, 2012 at 12:37 PM
Hi! I have installed Apacha Tomcat 7 ,mysql 5.5 and eclipse 4.2.I copied mysql-connector-java-5.1.20-bin.jar to Apache/lib folder.When I make wizard based connection.The connection establishes successfully.But when I use programming package DataAccessWithJava; import java.sql.*; import java.lang.*; public class MysqlConnect{ public static void main(String[] args) { System.out.println("MySQL Connect Example."); Connection conn = null; String url = "jdbc:mysql://localhost:3306/test"; String dbName = "test"; String driver = "com.mysql.jdbc.Driver"; String userName = "root"; String password = "root"; try { Class.forName(driver).newInstance(); conn = DriverManager.getConnection(url+dbName,userName,password); System.out.println("Connected to the database"); conn.close(); System.out.println("Disconnected from database"); } catch (Exception e) { e.printStackTrace(); } } } java.lang.ClassNotFoundException: com.mysql.jdbc.Driver this error occurs and no help is available
Post your Comment