Cannot create JDBC driver of class '' for connect URL 'null'问题解决

Cannot create JDBC driver of class ‘‘ for connect URL ‘null‘问题解决方法1

严格来说也不叫错 只是不同的版本写法不一样

tomcat-5.0.28是这种形式

<Resource name="jdbc/conn" type="javax.sql.DataSource"/>

<ResourceParams name="jdbc/conn">

<parameter>

<name>maxWait</name>

<value>5000</value>

</parameter>

<parameter>

<name>maxActive</name>

<value>10</value>

</parameter>

<parameter>

<name>password</name>

<value>tiger</value>

</parameter>

<parameter>

<name>url</name>

<value>jdbc:oracle:thin:@localhost:oracle</value>

</parameter>

<parameter>

<name>driverClassName</name>

<value>oracle.jdbc.driver.OracleDriver</value>

</parameter>

<parameter>

<name>maxIdle</name>

<value>1</value>

</parameter>

<parameter>

<name>username</name>

<value>scott</value>

</parameter>

</ResourceParams>

但是apache-tomcat-6.0.32就得这种形式

<Resource name="jdbc/conn" auth="Container" type="javax.sql.DataSource"

maxActive="10" maxIdle="1" maxWait="5000"

username="scott" password="tiger" driverClassName="com.mysql.jdbc.Driver"

url="jdbc:mysql://localhost:3306/neusys"/>

Cannot create JDBC driver of class ‘‘ for connect URL ‘null‘问题解决方法2

1)启动Tomcat服务器,打开浏览器,输入http://localhost:8080/admin(其中localhost是名称服务器或称为主机),

进入管理界面的登陆页面,这时候请输入原来安装时要求输入的用户名和密码,登陆到管理界面,

2)选择Resources-Data sources进入配置数据源界面,选择
 Data Source Actions ->选择Create New
Data Source,进入配置详细信息界面
主要内容例如下:
JNDI Name:   ->jdbc/mysql
Data Source URL 
->jdbc:mysql://localhost:3306/test
JDBC Driver Class-> org.gjt.mm.mysql.Driver
3)修改\conf\Catalina\localhost目录下建立一个xml文件,名称为你所发布的web应用的名称.xml,(如testpool.xml)打开添加内容如下:

<?xml version="1.0"
encoding="UTF-8"?>
<Context>
 <Resource
     
name="jdbc/mysql"
     
type="javax.sql.DataSource"
     
password="123456"
     
driverClassName="org.gjt.mm.mysql.Driver"
     
maxIdle="2"
     
maxWait="50"
     
username="root"
     
url="jdbc:mysql://localhost:3306/test"
     
maxActive="4"/>

</Context>
内容同conf/server.xml中<GlobalNamingResources>

<Resource
     
name="jdbc/mysql"
     
type="javax.sql.DataSource"
     
password="123456"
     
driverClassName="org.gjt.mm.mysql.Driver"
     
maxIdle="2"
     
maxWait="50"
     
username="root"
     
url="jdbc:mysql://localhost:3306/test"
     
maxActive="4"/>
 
</GlobalNamingResources>

少了这一步会报错:Cannot create JDBC driver of class ‘‘ for connect URL
‘null‘
4)修改web.xml

打开%TOMCAT_HOME%\conf\web.xml或yourwebapp/web-inf/web.xml,添加以下内容:

<resource-ref>
   
<description>DB
Connection</description>
   
<res-ref-name>jdbc/mysql</res-ref-name>

<res-type>javax.sql.DataSource</res-type>

<res-auth>Container</res-auth>

</resource-ref>
   
注意res-ref-name填写的内容要与在上文提到的JNDI Name名称一致。 
 到这里,配置工作就基本完成了!

5)引用JNDI时用"java:comp/env/jdbc/mysql";
建立文件测试 test.jsp:
<%@page contentType="text/html;charset=utf-8"
%>
<%@page import="java.sql.*"
%>
<%@page import="javax.sql.*"
%>
<%@page import="javax.naming.*"
%>
<html>
<head>
<title>Tomcat连接池测试</title>

</head>
<body>
<%
  Context ctx=new InitialContext();
  Connection conn=null;
  DataSource
ds=(DataSource)ctx.lookup("java:comp/env/jdbc/mysql");
  conn=ds.getConnection();
  Statement
stmt=conn.createStatement(ResultSet.CONCUR_READ_ONLY,ResultSet.CONCUR_UPDATABLE);

ResultSet rs=stmt.executeQuery("select * from
testexample");
  while(rs.next()){
  out.println(rs.getInt(1));
  out.println(rs.getString(2));
  out.println(rs.getString(3));
  }
  out.println("数据库操作成功!");
  rs.close();
  stmt.close();
  conn.close();

%>
</body>
</html>

Cannot create JDBC driver of class '' for connect URL 'null'问题解决

时间: 2024-10-11 16:52:01

Cannot create JDBC driver of class '' for connect URL 'null'问题解决的相关文章

JNDI数据源局部配置(解决Cannot create JDBC driver of class &#39;&#39; for connect URL &#39;null&#39;)

最开始,我是借鉴 孤傲苍狼的JNDI教程去做的,他讲得很详细,但是坏处也就是因为他讲的太详细.查了很多书,都是建议说不要用全局去配置JNDI,一是要修改tomcat的server.xml,容易破坏tomcat ,其次是那样吃力不讨好.我是建议用局部变量就好的. 1.步骤一:学习配置JNDI之前,介绍你一定要先掌握tomcat的配置虚拟目录(可以去看Tomcat中主目录配置与虚拟目录配置问题这样的文章,也可以去我的tomcat配置虚拟目录 -思维焦点网易博客找类似的链接).学习了tomcat的配置

Cannot create JDBC driver of class &#39;&#39; for connect URL &#39;null&#39;

1.错误描述 严重: 抛出了"org.apache.tomcat.dbcp.dbcp.SQLNestedException"异常:Cannot create JDBC driver of class '' for connect URL 'null' 堆栈: org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(1452). org.apache.tomcat.dbcp.dbcp.BasicDataSou

SQLNestedException: Cannot create JDBC driver of class &#39;&#39; for connect URL &#39;null&#39; 解决办法

当跑jndi项目时抛出:org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'异常 解决办法: 1.在Tomcat 6.0\lib下加入oracle驱动包ojdbc14_g-10.2.0.1.0.jar 2.在Tomcat 6.0\conf下的context.xml文件中加入 [javascript] view plaincopy <R

Cannot create JDBC driver of class &#39;com.p6spy.engine.spy.P6SpyDriver&#39;

Cannot create JDBC driver of class 'com.p6spy.engine.spy.P6SpyDriver' 开始不知为何报如此错,因为用IronTrackSQL已经不是一次两次了 jar包,spy.properties都应该没问题,但是就是报这个错. 后来在网上查到,把spy.properties放到tomcat/bin目录下即可解决该问题. 这种问题真想仔细检查检查到底问题出在什么地方... Cannot create JDBC driver of class

com.mysql.jdbc.Driver 和 com.mysql.cj.jdbc.Driver的区别

调试代码时,发现错误: Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary. 在网上巴拉巴拉发现,原

java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver

java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) at java

tomcat启动过程报the JDBC Driver has been forcibly unregistered问题的修复过程

最近两天在整理关于flume的总结文档,没有启动过tomcat.昨天晚上部署启动,发现报了如题的错误,全文如下: 严重: The web application [/oa-deploy] registered the JBDC driver [com.microsoft.sqlserver.jdbc.SQLServerDriver] but failed to unregister it when the web application was stopped. To prevent a mem

To prevent a memory leak, the JDBC Driver has been forcibly unregistered.

1.错误描述 严重: The web application [/AMST] registered the JDBC driver [org.logicalcobwebs.proxool.ProxoolDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. 八

registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped.

最近在用maven整合SSH做个人主页时候,在eclipse里面使用tomcat7插件发布项目是没有问题的,但当打包成war之后,使用tomcat7单独发布项目,就出现了以下的错误. 严重: Context [/wangxin] startup failed due to previous errors 八月 16, 2017 7:29:12 下午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc 严重: T