标题:找不到com.mysql.jdbc.Driver
取消只看楼主
qa22qa22
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2009-7-15
结帖率:100%
已结贴  问题点数:20 回复次数:0 
找不到com.mysql.jdbc.Driver
我用mysql创建了个student表,然后mysql服务也启动了
   用myeclipse加载驱动是说找不到,问下原因,代码下面:

package hcl;
import java.sql.*;
public class test {
public static void main(String[] args) {
        try{
            Class.forName("com.mysql.jdbc.Driver");        //加载驱动
            Connection con=DriverManager.getConnection("jdbc:mysql://localhos:3306/student", "root", "root");
                                                        //说明数据库URL,链接数据库
            Statement stm=con.createStatement();
            String str="select * from student;";        //构造SQL语句
            stm.executeUpdate(str);
            ResultSet rs=stm.executeQuery(str);
            while(rs.next()){                            //执行结果
                System.out.print(rs.getInt(1)+" ");                
                System.out.print(rs.getString(2)+" ");
                System.out.print(rs.getInt(3)+" ");
                System.out.println(rs.getInt(4));                
            }
            stm.close();
            con.close();
            
        }
        catch(Exception e){
                        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 hcl.test.main(test.java:9)
搜索更多相关主题的帖子: mysql jdbc Driver 
2009-07-15 02:17



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-279588-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.294271 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved