Java开发网 |
注册 |
登录 |
帮助 |
搜索 |
排行榜 |
发帖统计
|
您没有登录 |
» Java开发网 » Architecture & Framework
» Struts
打印话题 寄给朋友 订阅主题 |
作者 | 多谢各位,已解决!!!配置struts数据源(dbcp)的错误 |
wilson751
发贴: 19 积分: 0 |
于 2005-01-24 12:24
高手指点: 环境: win2000 tomcat oracle 问题: 用struts配置数据源,来操作oracle数据库. 当在LogonAction.java文件中,取得DataSource对象时,报错如下: 2005-1-23 21:38:05 org.apache.struts.action.ActionServlet initModuleDataSources 严重: Initializing application data source test org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class ' ' for connect URL 'jdbc:oracle:thinlocalhost:1521:oradb' at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSou rce.java:780) at org.apache.commons.dbcp.BasicDataSource.setLogWriter(BasicDataSource. java:598) at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionSe rvlet.java:778) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:331) at javax.servlet.GenericServlet.init(GenericServlet.java:211) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper. java:1019) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:86 2) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContex t.java:3991) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4 335) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase .java:823) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:80 7) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595) at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDep loyer.java:277) at org.apache.catalina.core.StandardHost.install(StandardHost.java:832) at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:613 ) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:431 ) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:964) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java :349) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl eSupport.java:119) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091) at org.apache.catalina.core.StandardHost.start(StandardHost.java:789) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478 ) at org.apache.catalina.core.StandardService.start(StandardService.java:4 76) at org.apache.catalina.core.StandardServer.start(StandardServer.java:229 8) at org.apache.catalina.startup.Catalina.start(Catalina.java:556) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:284) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:422) Caused by: java.sql.SQLException: No suitable driver at java.sql.DriverManager.getDriver(DriverManager.java:243) at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSou rce.java:773) ... 31 more 配置步骤: tomcat5/common/lib/下,添加了如下个jar包: commons-dbcp-1.2.jar struts-legacy.jar commons-pool-1.2.jar classes12.jar 下面是struts-config.xml和LogonAction.java, ---------struts-config.xml <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"> <struts-config> <!-- ======== Oracle DataSource Definitions ============================ --> <data-sources> <data-source key="test" type="org.apache.commons.dbcp.BasicDataSource" > <set-property property="autoCommit" value="false"/> <set-property property="description" value="Database for equipment of System"/> <set-property property="driverClass" value="oracle.jdbc.driver.OracleDriver"/> <set-property property="maxCount" value="10"/> <set-property property="minCount" value="1"/> <set-property property="url" value="jdbc:oracle:thinlocalhost:1521:oradb"/> <set-property property="user" value="testsystem"/> <set-property property="password" value="testsystem"/> </data-source> </data-sources> <!-- ========== Action Mapping Definitions ============================== --> <action-mappings> <action path = "/LogonCheck" parameter = "logon" type = "logon.LogonAction" name = "LogonForm" scope = "request" validate = "false" input = "/logon.jsp" > <forward name="testLogon" path="/main.jsp" /> <forward name="failure" path="/failure.jsp" /> </action> <action path = "/UserManage" type = "user.UserManageAction" name = "UserManageForm" scope = "request" validate = "false" input = "/addUser.do" > </action> </action-mappings> <!-- ========== Message Resources Definitions =========================== --> <message-resources parameter="resourcebundles.application"/> </struts-config> ------------------LogonAction.java package logon; import java.sql.*; import javax.sql.*; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpSession; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionMessage; import org.apache.struts.action.ActionMessages; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.util.MessageResources; import org.apache.commons.beanutils.BeanUtils; public final class LogonAction extends Action{ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { DataSource dataSource = null; Connection cnn = null; try { dataSource = getDataSource(request,"test"); cnn = dataSource.getConnection(); } catch (SQLException e) { getServlet().log("处理数据库连接", e); } finally { // 在finally块里包含这些代码 // 用以保证连接最后会被关闭 try { cnn.close(); } catch (SQLException e) { getServlet().log("关闭数据库连接", e); } } return mapping.findForward("testLogon"); } }
wilson751 edited on 2005-02-01 18:07
Java应用者与<IDE/环境> |
话题树型展开 |
人气 | 标题 | 作者 | 字数 | 发贴时间 |
16914 | 多谢各位,已解决!!!配置struts数据源(dbcp)的错误 | wilson751 | 7541 | 2005-01-24 12:24 |
14715 | Re:高手sos!!!配置struts数据源(dbcp)的错误 | glistar | 19 | 2005-01-24 16:14 |
14698 | Re:高手sos!!!配置struts数据源(dbcp)的错误 | wilson751 | 27 | 2005-01-24 19:41 |
14692 | Re:高手sos!!!配置struts数据源(dbcp)的错误 | glistar | 144 | 2005-01-25 08:40 |
14722 | Re:高手sos!!!配置struts数据源(dbcp)的错误 | wilson751 | 3349 | 2005-01-25 22:49 |
14709 | Re:高手sos!!!配置struts数据源(dbcp)的错误 | glistar | 103 | 2005-01-26 09:27 |
14622 | Re:高手sos!!!配置struts数据源(dbcp)的错误 | wilson751 | 7 | 2005-01-26 10:32 |
15606 | Re:高手sos!!!配置struts数据源(dbcp)的错误 | wilson751 | 81 | 2005-01-26 10:36 |
已读帖子 新的帖子 被删除的帖子 |
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 |