当前位置: 代码迷 >> Java Web开发 >> Cannot create JDBC driver of class '' for connect URL 'null' !
  详细解决方案

Cannot create JDBC driver of class '' for connect URL 'null' !

热度:821   发布时间:2016-04-17 13:58:39.0
Cannot create JDBC driver of class '' for connect URL 'null' !!!!!!!!!!!!!!!!
求高人指点迷津!晕死了
JBuild2006+SQLServer+Tomcat5.0.28
数据库打过SP4补丁。。
我的数据库连接池配置:
1.已经将3个SQLServer驱动jar放到\common\lib下。
2.Tomcat是进入http://localhost:8080/admin配置的。
3.工程的web.xml:    
<resource-ref>
        <description> DBCP </description>
        <res-ref-name> jdbc/sqlserver </res-ref-name>
        <res-type> javax.sql.DataSource </res-type>
        <res-auth> Container </res-auth>
  </resource-ref>
4.工程中lib也导入了3个jar包。
为什么仍然报错。。

这是代码:
try   {
    Context   ctx=new   InitialContext();
        if(ctx==null)   throw   new   Exception( "没有匹配的环境 ");
        DataSource   ds=(DataSource)ctx.lookup( "java:comp/env/jdbc/sqlserver ");
        if(ds==null)   throw   new   Exception( "没有匹配数据库 ");        
    if(ds!=null){
        out.println( "OK! ");
        out.println( " <br> ");
        out.println( "jdbc   begin ");
        Connection   con   =   ds.getConnection();
        out.println( "con   success ");
        Statement   st   =   con.createStatement();
        out.println( "st   success ");
        ResultSet   rs   =   st.executeQuery( "select   *   from   products ");
        out.println( "rs   success ");
        out.println( "以下是从数据库中读取出来的数据 ");
        while(rs.next())
        {
            out.println( "producer: "+rs.getString( "producer "));
            out.println( " <br> ");
        }
    }
    else{
        out.println( "连接失败 ");
    }
}
catch   (Exception   ex)   {
    out.println(ex);
}

这是报错提示:
OK!   jdbc   begin
org.apache.commons.dbcp.SQLNestedException:   Cannot   create   JDBC   driver   of   class   ' '   for   connect   URL   'null '  

为什么啊?!

再问一个小白的问题:
JBuilder2006原来使用tomcat5.5后来我改路径换成5.0了,JBulider2006中启动tomcat,为什么IE里输入http://localhost:8080打不开?我的环境变量也改过了!

求解!

------解决方案--------------------
MS路径错误 LZ自己看一下
------解决方案--------------------
你先不要用连接池,先用JDBC直连试一试,如果有问题的话就是你的补丁没有打好,如果直连没有问题的话就是你的连接池路径配置的不正确
------解决方案--------------------
补丁有问题吧,我以前写过一个小程序,结果发现直接连jdbc跟本连不上数据库,后来配了一个jdbc-odbc驱动才连上(测试程序,无性能要求)
  相关解决方案