mysql 的 jdbc 驱动没加进来

解决方案 »

  1.   

    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    找不到mysql驱动,你把mysql的jar包拷贝到工程下的WEB-INF下的lib就行了。
      

  2.   

    少了 mysql  的jar 。。
      

  3.   

    加进去了,用buildpath->add external jars试了一遍不行,网上还有说把驱动加到web项目的lib中,依然不行,而且显示的异常都一样
      

  4.   

    你是不是拷重复了?删了重新拷,拷到web中lib
      

  5.   

    ctrl+shift+r,看看能不能看见你的jar包,能看见就是导进来了,看不见就是没有
      

  6.   

    myeclipse最好办了,它的部署是直接复制到tomat/webapps下,只看看你应用的lib下是否有mysql的驱动
      

  7.   


    java.lang.NullPointerException
    at com.dong.main.update.getMenuList(update.java:39)

    空指针了,
    update.java:39
    看看这里怎么写的
      

  8.   

    这是update.Java文件,调用的是工具类来实现的数据库连接
    package com.dong.main;
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.ArrayList;
    import java.util.List;import com.dong.util.DBUtil;public class update {
    public List<Menu> getMenuList(){
    //数据库查询语句
    String sql="select course_id,课程名称,课程号,主讲教师姓名,节次,星期,周次分布,教室 from course_table";
    DBUtil util=new DBUtil();
    //获得连接
    Connection conn=util.openConnection();
    try{
    Statement pstmt=conn.createStatement();
    ResultSet rs=pstmt.executeQuery(sql);
    List<Menu> list=new ArrayList<Menu>();
    //获取数据库课程表信息
    for(int i=0;i<10;i++,rs.next()){
    int courseId=rs.getInt(1);
    String courseName=rs.getString(2);
    String courseNum=rs.getString(3);
    String teacherName=rs.getString(4);
    String courseTime=rs.getString(5);
    int week=rs.getInt(6);
    String weekNum=rs.getString(7);
    String coursePlace=rs.getString(8);

    Menu m=new Menu();

    m.setCourseId(courseId);
    m.setCourseName(courseName);
    m.setCourseNum(courseNum);
    m.setCoursePlace(coursePlace);
    m.setCourseTime(courseTime);
    m.setTeacherName(teacherName);
    m.setWeek(week);
    m.setWeekNum(weekNum);


    list.add(m);
    }
    return list;
    }catch(SQLException e){
    e.printStackTrace();
    }finally{

    if(conn!=null){
    util.closeConn(conn);
    }

    }
    return null;
    }
    }这是数据库连接的代码package com.dong.util;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.util.Properties;
    public class DBUtil {
     

    /* 
         * 打开数据库连接 
         */  
        public Connection openConnection() {  
            Properties prop = new Properties();  
            String driver = null;  
            String url = null;  
            String username = null;  
            String password = null;    
            try {  
                prop.load(this.getClass().getClassLoader().getResourceAsStream("DBConfig.properties"));    
                driver = prop.getProperty("driver");  
                url = prop.getProperty("url");  
                username = prop.getProperty("username");  
                password = prop.getProperty("password");                
                Class.forName(driver);  
                return DriverManager.getConnection(url, username, password);  
            } catch (Exception e) {  
                e.printStackTrace();  
            }    
            return null;  
        }  
        
        
        public void closeConn(Connection conn){  
            try {  
                conn.close();  
            } catch (SQLException e) {  
                e.printStackTrace();  
            }  
        }  
    }
    连接语句写在了一个属性文件中:<span style\="font-size\:18px;">
    driver=com.mysql.jdbc.Driver  
    url=jdbc\:mysql\://localhost\:3306/schedule?useUnicode\=true&characterEncoding\=utf-8  
    username=root  
    password=dong123
    </span>  
      

  9.   

    不知道MySQL的驱动版本有要求没?我的MySQL是最新版本的,调用的驱动文件是mysql-connector-java-5.1.30,并且同样的代码用Java工程就可以连接到数据库,而部署到web中就出现了以上异常。
      

  10.   

    导入jar包后 tomcat内项目是否重新部署过了