Topic: javax.naming.NamingException |
Print this page |
1.javax.naming.NamingException | Copy to clipboard |
Posted by: lijianjun0379 Posted on: 2007-06-03 16:25 错误提示: javax.naming.NamingException: Could not create resource factory, ClassNotFoundException:org.apache.commons.dbcp.BasicDateSourceFactory 谁知道是什么原因 捆饶我两个星期了 |
2.Re:javax.naming.NamingException [Re: lijianjun0379] | Copy to clipboard |
Posted by: lijianjun0379 Posted on: 2007-06-03 16:36 server.xml如下: <Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="localhost_log." suffix=".txt" timestamp="true"/> <Context path="/jspdev" docBase="e:\jspdev" debug="0" reloadable="true" crossContext="true"> <Resource name="jdbc/jspdev" auth="Container" type="javax.sql.DateSource"/> <ResourceParams name="jdbc/jspdev"> <parameter> <name>factory</name> <value>org.apache.commons.dbcp.BasicDateSourceFactory</value> </parameter> <parameter> <name>driverClassName</name> <value>net.sourceforge.jtds.jdbc.Driver</value> </parameter> <parameter> <name>url</name> <value>jdbc:jtds:sqlserver://127.0.0.1:1433;DatabaseName=jspdev</value> </parameter> <parameter> <name>username</name> <value>sa</value> </parameter> <parameter> <name>password</name> <value>sa</value> </parameter> <parameter> <name>maxActive</name> <value>20</value> </parameter> <parameter> <name>maxIdle</name> <value>10</value> </parameter> <parameter> <name>maxWait</name> <value>-1</value> </parameter> <parameter> <name>removeAbandoned</name> <value>true</value> </parameter> <parameter> <name>removeAbandonedTimeout</name> <value>60</value> </parameter> <parameter> <name>logAbandoned</name> <value>true</value> </parameter> </ResourceParams> </Context> </Host> -------------------------------------------------------------------- web.xml配置如下; <resource-ref> <description>DataSource</description> <res-ref-name>jdbc/jspdev</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> ------------------------------------------------------------------ jsp源代码: <%@ page contentType="text/html; charset=GBK"%> <%@ page import="java.sql.*,javax.sql.DataSource,javax.naming.*"%> <html> <head><title>test.jsp</title></head> <body bgcolor="#ffffff"> <h1>出来吧!</h1> <% try { Context initCtx=new InitialContext(); DataSource ds=(DataSource)initCtx.lookup("java:comp/env/jdbc/jspdev"); Connection conn=ds.getConnection(); out.println("data from database:<br>"); Statement stmt=conn.createStatement(); ResultSet rs =stmt.executeQuery("select * from user_info"); while(rs.next()) { out.println(rs.getInt("userid")); out.println(rs.getString("name")); out.println(rs.getString("city")); } rs.close(); stmt.close(); } catch(Exception ne) { out.println(ne); } %> 各位帮帮我看看是什么原因。 |
3.Re:javax.naming.NamingException [Re: lijianjun0379] | Copy to clipboard |
Posted by: snowbug Posted on: 2007-06-11 13:31 找不到你的 DBCP 库文件。从 jakarta.apache.com 下载,放到 lib 目录下 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |