求助JAVA连接MYSQL数据库的问题
//DatabaseConnection.javapackage mypackage;
import java.sql.*;
public class DatabaseConnection {
public static void main(String [] args)
{
String driver = "com.MySQL.jdbc.Driver";
String url = "jdbc:MySQL://localhost/mydatabase";
String user = "root";
String password = "123456";
try
{
Class.forName(driver);
Connection con = DriverManager.getConnection(url,user,password);
String insert = "insert friends(id,name) values(?,?)";
PreparedStatement prestatement = con.prepareStatement(insert);
String [] names = {"Rachel","Rose","Phoebe","Monica","Chandler","Joey"};
for(int i = 0;i < 6;i++ )
{
prestatement.setInt(1,i);
prestatement.setString(2,names);
prestatement.execute();
}
String query = "select * from friends";
ResultSet result = prestatement.executeQuery(query);
System.out.println("The Results is:");
while (result.next())
{
System.out.println(result.getString("name"));
}
con.close();
}catch(SQLException e)
{
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
错误信息如下:
java.lang.ClassNotFoundException: com.MySQL.jdbc.Driver
at (Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at (Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at mypackage.DatabaseConnection.main(DatabaseConnection.java:17)
请各位高手帮忙看看这个错误是什么原因导致的好吗/??
谢谢哈~~~~~~~~~~~