我用com.mysql.jdbc.Driver连我机器上的MySQL数据库为什么出错?
已经在本机上的MySQL数据库里面建了一个Studentdb的数据库
create database studentdb;
也做了GRANT all on studentdb.* to test@127.0.0.1 IDENTIFIED BY 'test';
在MySQL里面显示数据库都建好了。当然,开启了数据库。
然后在java程序里面用:
...
String dbName="studentdb";
String username="test";
String password="test";
Class.forName("com.mysql.jdbc.Driver");
String dbURL="jdbc:mysql://127.0.0.1:3306"/"+dbName;
Connection con=DriverManager.getConnection(dbURL,userName,password);
...
结果出错:Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
谁能告诉我错在哪里吗?