连接不上数据库啊。。大神帮忙看看
package jdbc_imooc; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class DBUtil { private static final String URL="jdbd:mysql://localhost:3306/imooc"; private static final String NAME="root"; private static final String PASSWORD="789456"; public static void main(String[] args) throws Exception{ //1.加载驱动程序 Class.forName("com.mysql.jdbc.Dirver"); //2.获得数据库的连接 Connection conn=DriverManager.getConnection(URL,NAME,PASSWORD); //3.操纵数据库 Statement stmt = conn.createStatement(); ResultSet rs=stmt.executeQuery("select user_name,age from imooc_goddess"); while(rs.next()){ System.out.println(rs.getString("user_name")+","+rs.getInt("age")); } } }
代码就完全是按照老师的敲的,环境变量也加载了啊 可总是抛异常
Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.jdbc.Dirver
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 jdbc_imooc.DBUtil.main(DBUtil.java:17)