web.xml代码<resource-ref>
<description>Oracle Datasource example</description>
<res-ref-name>USHARP_TOMCAT</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>tomcat的配置代码<Context>
<Resource name="USHARP_TOMCAT" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="root" password="" driverClassName="org.gjt.mm.mysql.Driver"
url="jdbc:mysql://192.168.11.190/crf_usharp_web"/></Context>java代码Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:/comp/env");
DataSource ds = (DataSource) envContext.lookup("USHARP_TOMCAT");
Connection conn = ds.getConnection();
ResultSet rs=conn.prepareStatement("select mer_id from web_mer_info").executeQuery();
System.out.println(rs);
一样的代码,在tomcat6下面运行可以获得数据源并且获得连接都可以,但是在tomcat5.5下面出错.
异常代码为:
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' DataSource ds = (DataSource) envContext.lookup("USHARP_TOMCAT");
Connection conn = ds.getConnection();//从这里引发异常
<description>Oracle Datasource example</description>
<res-ref-name>USHARP_TOMCAT</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>tomcat的配置代码<Context>
<Resource name="USHARP_TOMCAT" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="root" password="" driverClassName="org.gjt.mm.mysql.Driver"
url="jdbc:mysql://192.168.11.190/crf_usharp_web"/></Context>java代码Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:/comp/env");
DataSource ds = (DataSource) envContext.lookup("USHARP_TOMCAT");
Connection conn = ds.getConnection();
ResultSet rs=conn.prepareStatement("select mer_id from web_mer_info").executeQuery();
System.out.println(rs);
一样的代码,在tomcat6下面运行可以获得数据源并且获得连接都可以,但是在tomcat5.5下面出错.
异常代码为:
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' DataSource ds = (DataSource) envContext.lookup("USHARP_TOMCAT");
Connection conn = ds.getConnection();//从这里引发异常
解决方案 »
- 紧急!maven的eclipse找不到本地仓库的的jar包
- 关于JSTL 转换unicode 的问题 求解。
- A server error has occured.More information may be available in the console.
- 请教一个关于HIBERNATE查询时候大小写的问题
- 在struts测试中出现这个错误
- 数据源问题.
- 关于xml的:我查了很多网上资源,都是互相抄袭,都不对(在线等待)
- 初学者问题,各位大虾指点!!!(在线等待)
- 初学spring的注解,报错,求解
- Java 错误the declared package dones not match the expected package ""
- 上传下载文件 jsmart怎么用
- javaBean 的问题,大家进来看下......
6.0写context.xml