源代码:
*************************************************************************************
import java.sql.*;
public class First
{
public static void main(String args[]) throws SQLException
{
String ur1 = "abccs";
String password = "abc";
String ur2 = "jdbc:mysql://localhost:3306/abccs";
try
{
Class.forName("com.mysql.jdbc.Driver");
}
catch (ClassNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
try
{
Connection con;
con=DriverManager.getConnection(ur2,ur1,password);
Statement s=con.createStatement();
String query = "create table student2("+"id char(10),"+"score integer"+")";
s.executeUpdate(query);
s.close();
con.close();
}
catch(SQLException e)
{
System.out.print("SQLException"+e.getMessage());
}
}
}
错误提示:
**********************************************************************************
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(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.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at First.main(First.java:12)
SQLExceptionNo suitable driver found for jdbc:mysql://localhost:3306/abccs
************************************************************************************
这个问题我做了将近3天了,不知道是我的JHDBC驱动程序错误,还是代码本身的错误,或者说是Mysql中的错误
希望大家能帮忙解决下,谢谢 !
--转自